嵌套文档弹性搜索中的字段分析

2024-10-04 07:35:30 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用一个嵌套结构的文档,尽管我告诉它“未分析”,但它的内容仍在分析中。文件定义如下:

class SearchDocument(es.DocType)
    # Verblijfsobject specific data
    gebruiksdoel_omschrijving = es.String(index='not_analyzed')
    oppervlakte = es.Integer()
    bouwblok = es.String(index='not_analyzed')
    gebruik = es.String(index='not_analyzed')
    panden = es.String(index='not_analyzed')

    sbi_codes = es.Nested({
        'properties': {
            'sbi_code': es.String(index='not_analyzed'),
            'hcat': es.String(index='not_analyzed'),
            'scat': es.String(index='not_analyzed'),
            'hoofdcategorie': es.String(fields= {'raw': es.String(in dex='not_analyzed')}),
            'subcategorie': es.String(fields={'raw':es.String(index='not_analyzed')}),
            'sub_sub_categorie': es.String(fields= {'raw': es.String(index='not_analyzed')}),
            'bedrijfsnaam': es.String(fields= {'raw': es.String(index='not_analyzed')}),
            'vestigingsnummer': es.String(index='not_analyzed')
        }
})

很明显,文件中对大多数领域都说“未分析”。这对于“常规字段”是可行的。问题出在嵌套结构中。在那里,hoofdcategorie和其他字段被索引为它们各自的单词,而不是未分析的版本

结构中填充了以下数据:

[
  {
    "sbi_code": "74103",
    "sub_sub_categorie": "Interieur- en ruimtelijk ontwerp",
    "vestigingsnummer": "000000002216",
    "bedrijfsnaam": "Flippie Tests",
    "subcategorie": "design",
    "scat": "22279_12_22254_11",
    "hoofdcategorie": "zakelijke dienstverlening",
    "hcat": "22279_12"
  },
  {
    "sbi_code": "9003",
    "sub_sub_categorie": "Schrijven en overige scheppende kunsten",
    "vestigingsnummer": "000000002216",
    "bedrijfsnaam": "Flippie Tests",
    "subcategorie": "kunst",
    "scat": "22281_12_22259_11",
    "hoofdcategorie": "cultuur, sport, recreatie",
    "hcat": "22281_12"
  }
]

现在,当我检索聚合时,它已经将hoofd分类分成3个不同的词(“cultuur”,“sport”,“recreatie”)。这不是我想要的,但据我所知,我已经用“未分析”这句话正确地说明了这一点

有什么想法吗


Tags: fieldsstringindexrawesnotcode结构