【发布时间】:2017-08-20 12:45:32
【问题描述】:
假设我有一个索引,并且我添加了一些文档,使用以下语句:
POST test/item/_bulk
{"id": 1, "text": "one two"}
{"id": 2, "text": "one two three"}
{"id": 3, "text": "three one two"}
{"id": 4, "text": "three one two four"}
{"id": 5, "text": "one two|"}
{"id": 6, "text": "|one two"}
{"id": 7, "text": "|one two|"}
{"id": 8, "text": "one|two"}
{"id": 9, "text": "one| two"}
{"id": 10, "text": "one |two"}
{"id": 11, "text": "one | two"}
我想要这个搜索:
GET test/item/_search
{
"query":
{
"query_string":
{
"query": "\"one two\"",
"fields": ["text"],
"analyze_wildcard": "true",
"allow_leading_wildcard": "true",
"default_operator": "AND"
}
}
}
返回文档1-7。
我在文档和查询中尝试了各种分析器和标记器(std、空格等),但它们都没有给我想要的结果。
例如,std 分析器返回所有文档,而空白分析器只返回 1-4。
是否有可以返回所需结果的分析器/标记器/参数?
注意:为了清楚起见,我的数据由没有共同特征的短字符串和 非常 长字符串组成。我给出的单词(一、二、三、四)和符号(|)只是为了方便起见,可以替换为任何其他单词和非单词字符。
【问题讨论】:
标签: elasticsearch