请显示您的映射类型,但是我怀疑您的
tags字段是一个简单的
string字段,如下所示:
{ "your_type" : { "properties" : { "tags" : { "type" : "string" } } }}在这种情况下,ES会
tags在索引编制时将字段中的所有标签“扁平化” ,如下所示:
tags: "stuff", "like", "this", "that"
即,这就是为什么在查询“东西”时得到结果的原因,因为该
tags字段包含两个单词。
前进的方法是制作
tags一个嵌套的对象类型,像这样
{ "your_type" : { "properties" : { "tags" : { "type" : "nested", "properties": { "tag" : {"type": "string" } } } } }}您需要重新索引数据,但至少查询
tags: "stuff that"将不再返回任何内容。您的标记令牌将按照您的期望“保持在一起”。试试看。



