Python Wagtail:Elasticsearch不会在短字段上增加匹配
我们正在构建一个搜索模型,其中包含街道、街道号和城市。在streetnumber上进行精确匹配应该会使结果达到最高,但我们无法使其发挥作用,有什么想法吗 后端设置:Python Wagtail:Elasticsearch不会在短字段上增加匹配,python,elasticsearch,wagtail,Python,elasticsearch,Wagtail,我们正在构建一个搜索模型,其中包含街道、街道号和城市。在streetnumber上进行精确匹配应该会使结果达到最高,但我们无法使其发挥作用,有什么想法吗 后端设置: "default": { "BACKEND": "wagtail.search.backends.elasticsearch7", "URLS": [host.strip() for host in es_host.spl
"default": {
"BACKEND": "wagtail.search.backends.elasticsearch7",
"URLS": [host.strip() for host in es_host.split(",")],
"INDEX": APP_ENV_NAME,
"TIMEOUT": 5,
"OPTIONS": {},
"INDEX_SETTINGS": {
"settings": {
"analysis": {
# Replace default 'asciifolding' filter from Wagtail defaults.
# It converts non-ASCII characters (e.g. å -> a), breaking
# searches in Swedish. Adding preserve_original allows searching
# for both the original and the ASCII version.
"analyzer": {
"ngram_analyzer": {
"filter": ["asciifolding", "ngram"]
},
"edgengram_analyzer": {
"filter": ["asciifolding", "edgengram"]
},
},
"filter": {
"asciifolding": {
"type": "asciifolding",
"preserve_original": True,
}
},
}
}
},
}
}
search_fields = [
index.SearchField("street", partial_match=True),
index.SearchField("city", partial_match=True),
index.SearchField("street_nr"),
index.FilterField("active"),
]
模型设置:
"default": {
"BACKEND": "wagtail.search.backends.elasticsearch7",
"URLS": [host.strip() for host in es_host.split(",")],
"INDEX": APP_ENV_NAME,
"TIMEOUT": 5,
"OPTIONS": {},
"INDEX_SETTINGS": {
"settings": {
"analysis": {
# Replace default 'asciifolding' filter from Wagtail defaults.
# It converts non-ASCII characters (e.g. å -> a), breaking
# searches in Swedish. Adding preserve_original allows searching
# for both the original and the ASCII version.
"analyzer": {
"ngram_analyzer": {
"filter": ["asciifolding", "ngram"]
},
"edgengram_analyzer": {
"filter": ["asciifolding", "edgengram"]
},
},
"filter": {
"asciifolding": {
"type": "asciifolding",
"preserve_original": True,
}
},
}
}
},
}
}
search_fields = [
index.SearchField("street", partial_match=True),
index.SearchField("city", partial_match=True),
index.SearchField("street_nr"),
index.FilterField("active"),
]