gpt4 book ai didi

elasticsearch - Elasticsearch :查询不搜索数值

转载 作者:行者123 更新时间:2023-12-03 01:49:26 24 4
gpt4 key购买 nike

我在一个字段中存储了O5467508之类的值(以字母“O”开头)

以下是我的查询。

{"from":0,"size":10,"query":{"bool":{"must":[{"match":{"field_LIST_105":{"query":"o5467508","type":"phrase_prefix"}}},{"bool":{"must":[{"match":{"RegionName":"Virginia"}}]}}]}}}

它给了我正确的结果,但是当我只搜索数值“5467508”时,查询结果为空。

提前致谢。

最佳答案

可以帮助您的可能解决方案之一是使用word_delimiter过滤器以及preserve_original选项,该选项将保存原始 token 。

像这样:

{
"settings": {
"analysis": {
"analyzer": {
"so_analyzer": {
"type": "custom",
"tokenizer": "keyword",
"filter": [
"lowercase",
"my_word_delimiter"
]
}
},
"filter": {
"my_word_delimiter": {
"type": "word_delimiter",
"preserve_original": true
}
}
}
},
"mappings": {
"my_type": {
"properties": {
"field_LIST_105": {
"type": "text",
"analyzer": "so_analyzer"
}
}
}
}
}

我对分析进行了快速测试,这就是它给我的标记。
{
"tokens": [
{
"token": "o5467508",
"start_offset": 0,
"end_offset": 8,
"type": "word",
"position": 0
},
{
"token": "o",
"start_offset": 0,
"end_offset": 1,
"type": "word",
"position": 0
},
{
"token": "5467508",
"start_offset": 1,
"end_offset": 8,
"type": "word",
"position": 1
}
]
}

有关更多信息- https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-word-delimiter-tokenfilter.html

关于elasticsearch - Elasticsearch :查询不搜索数值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41610435/

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