ElasticSearch 没有显示精确匹配的正确结果

ElasticSearch not showing correct results for exactmatch

我正在尝试搜索完全匹配的字符串,但 ES 没有给我预期的结果。

下面是例子 -

这里是索引创建 -

POST /spacetesting1
{
    "settings" : {
        "number_of_shards" : 1
    },
    "mappings" : {
        "couchbaseDocument" : {
            "_source" : { "enabled" : false },
            "properties" : {
                "name" : { "type" : "string", "index" : "not_analyzed" }
            }
        }
    }
}

下面是我插入到索引中的 2 个文档 -

PUT /spacetesting1/CouchbaseDocument/7
{
  "name": "new york"
}

PUT /spacetesting1/CouchbaseDocument/8
{
  "name": "new York company"
}

当我搜索一个词 'new york' 时,ES 给了我 2 个文档,如上。但我只希望与 'new york'.

完全匹配

有人可以指导我如何从 ES 获得精确匹配吗?

提前致谢。

注意, 萨米尔

看来是个案问题。在映射中你给了 'couchbaseDocument' 而在索引时他给了 CouchbaseDocument.