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