gpt4 book ai didi

elasticsearch 按一个字母搜索

转载 作者:行者123 更新时间:2023-11-29 02:53:36 31 4
gpt4 key购买 nike

我有一个这样设置的索引:

settings: {
index.analysis.analyzer.eng_search_analyzer.filter.0: lowercase
index.analysis.analyzer.eng_search_analyzer.filter.1: icu_folding
index.analysis.analyzer.eng_search_analyzer.char_filter.0: html_strip
index.analysis.filter.eng_ngram_filter.type: nGram
index.analysis.filter.eng_ngram_filter.min_gram: 1
index.analysis.analyzer.eng_search_analyzer.tokenizer: whitespace
index.analysis.analyzer.eng_search_analyzer.filter.2: icu_normalizer
index.analysis.analyzer.eng_index_analyzer.filter.1: eng_ngram_filter
index.analysis.analyzer.eng_index_analyzer.filter.0: lowercase
index.number_of_shards: 2
index.analysis.filter.eng_ngram_filter.token_chars.1: digit
index.analysis.filter.eng_ngram_filter.token_chars.0: letter
index.analysis.filter.eng_ngram_filter.token_chars.3: symbol
index.analysis.filter.eng_ngram_filter.token_chars.2: punctuation
index.analysis.analyzer.eng_index_analyzer.type: custom
index.analysis.analyzer.eng_index_analyzer.char_filter.0: html_strip
index.analysis.analyzer.eng_index_analyzer.filter.3: icu_normalizer
index.analysis.filter.eng_ngram_filter.max_gram: 20
index.analysis.analyzer.eng_index_analyzer.filter.2: icu_folding
index.number_of_replicas: 1
index.analysis.analyzer.eng_index_analyzer.tokenizer: whitespace
index.analysis.analyzer.eng_search_analyzer.type: custom
index.version.created: 900799
index.uuid: -O-iV6ZIQh6gk1204Ec1ig
}

并且几个重要字段的字段映射是这样设置的:

{
"name": {
"type": "multi_field",
"fields": {
"name": {
"type": "string",
"index": "not_analyzed",
"omit_norms": "true",
"index_options": "docs",
"null_value": ""
},
"analyzed": {
"type": "string",
"index_analyzer": "eng_index_analyzer",
"search_analyzer": "eng_search_analyzer",
"null_value": "",
"include_in_all": "false"
}
}
}
}

当我查询 name.analyzed 字段时,它适用于至少包含两个字符的任何内容。例如,查询“Ra”将在名称字段中找到带有“Rafael”的文档。但是,当我查询“R”或“Rafael S”时,它没有返回任何结果。应该注意的是,在我们的查询中,空格被处理为“AND”运算符而不是“OR”,因此查询词基本上被处理为 - “name contains [search term]”。

如何配置字段或分析器以便搜索单个字母?

最佳答案

如果没有看到查询就很难说,但是根据 discussion on the elastic forum 的说法,如果您使用的是 match_phrase_prefix 查询,您可能会通过增加查询的“max_expansions”属性取得一些成功,尽管它会降低速度。

“max_expansions”:10000

该线程中的另一个潜在解决方案是将 operatordefault_operator 设置为 "and"(我想您已经完成了)。

关于elasticsearch 按一个字母搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28010474/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com