python - Wagtail:Elasticsearch 不会在短字段上提升匹配
问题描述
我们正在搜索具有街道、街道编号和城市的模型。streetnumber 上的完全匹配应该会将该结果放在首位,但我们无法让它发挥作用,有什么想法吗?
后端设置:
"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"),
]
解决方案
推荐阅读
- javascript - Express Router delete with mongoose 不适用于 ES8 语法
- json - 存储大量可查询的 JSON
- android - 如何使用渐变颜色为在bottomNavigationView中选择的图标着色
- javascript - JavaScript 中的@media 屏幕?
- visual-studio - Showing OutputDebugString messages with Window application?
- bash - 创建一个包含 bash 命令替换和参数的 git 别名
- angular - Template parse errors: There is no directive with "exportAs" set to "cdkDropList"
- sql-server - 在 SQL 中计算字符串中每个字母的出现次数
- kubernetes - My worker node status is Ready,SchedulingDisabled
- android - android:how to use viewflipper in listview to animate one row at a time