【发布时间】:2014-06-06 02:39:17
【问题描述】:
我有一个包含 4 个条目的索引。
"hits" : {
"total" : 4,
"max_score" : 1.0,
"hits" : [ {
"_index" : "da_6",
"_type" : "tweet",
"_id" : "1",
"_score" : 1.0, "_source" : {
"message" : "hello world"
}
}, {
"_index" : "da_6",
"_type" : "tweet",
"_id" : "2",
"_score" : 1.0, "_source" : {
"message" : "hello worldetc"
}
}, {
"_index" : "da_6",
"_type" : "tweet",
"_id" : "4",
"_score" : 1.0, "_source" : {
"message" : "etc hello world"
}
}, {
"_index" : "da_6",
"_type" : "tweet",
"_id" : "3",
"_score" : 1.0, "_source" : {
"message" : "hello etc world"
}
} ]
我在创建索引时已将映射设置为“string”/“not_analyzed”,我确信它已被应用。
映射:
"da_6" : {
"mappings" : {
"tweet" : {
"properties" : {
"message" : {
"type" : "string",
"index" : "not_analyzed"
}
}
}
}
}
当用户键入“hello w”时,我希望它首先显示第一个,然后是第二个和第三个。由于第四个不包含“hello w”作为一个完整的字符串,它不应该显示在结果中。
我试过query_string,搜索“hello w*”,但它显示了所有 4 个结果(似乎仍在标记内容。
是否有类似IndexOf (js) 的搜索方法给出的结果只包含给定的查询字符串(在这种情况下为“hello w”)?
【问题讨论】:
-
第四个条目在哪里?
-
我已经更新了我的问题。
-
您的查询的问题可能是您没有提供默认字段。比使用 _all 字段。如果您提供默认字段作为消息,您将获得其他结果。不过,我还没有(还)你的问题的答案。
标签: elasticsearch