gpt4 book ai didi

elasticsearch - ElasticSearch 5.2用空格分隔句子

转载 作者:行者123 更新时间:2023-12-02 22:30:24 29 4
gpt4 key购买 nike

我有以下字符串:

"hello world"
"hello"
"hello world all"

我的映射看起来像这样
...
"properties": {
"my_field": {
"type": "string",
"index": "not_analyzed"
}
}
...

当我尝试使用 simple_query_string进行搜索时:
{
"query": {
"simple_query_string" : {
"query": "hello"
}
}
}

我得到了所有三个字符串。

问题是我只需要一个与“hello”相关联的字符串。

最佳答案

使用 term query获得完全匹配

{
"query": {
"term" : {
"my_field": "hello"
}
}
}

请注意,在ES 5中,您可以通过指定 keyword类型来简化映射
"properties": {
"my_field": {
"type": "keyword"
}
}

关于elasticsearch - ElasticSearch 5.2用空格分隔句子,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42578285/

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