wagtail:elasticsearch不增强短字段上的匹配

6uxekuva  于 2021-06-10  发布在  ElasticSearch
关注(0)|答案(0)|浏览(300)

我们正在建立一个搜索模型与街道,街道号码和城市。在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"),
]

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题