Elasticsearch 在 like_text 中使用多个值模糊喜欢此查询

Elasticsearch fuzzylike this query with multiple values in like_text

我是 Elasticsearch 的新手。我们正在使用如下 fuzzy_like_this 查询

{
                      "query": {
                        "bool": {
                          "should": [
                            {
                              "flt": {
                                "fields": [
                                  "actor.id"
                                ],
                                "like_text": "kar@gmail.com"
                              }
                            }
                          ]
                        }
                      },
                      "size": "100",
                      "sort": [
                        {
                          "published": {
                            "order": "desc",
                            "ignore_unmapped": true
                          }
                        }
                      ]
                    }

like_text 当前匹配单个字符串,我们想修改它以搜索逗号分隔值,即 "like_text": "kar@gmail.com,xyz@yahoo.com"

我在 flt 中尝试了分析器和匹配选项,但无法获得预期的 result.Any 在这方面的帮助表示感谢。提前致谢。

您确定需要模糊查询吗?您是否尝试过仅使用 match query? You can configure lots of options, but by default the standard analyzer 将用于标记您的查询文本,并且它将标记为逗号。

作为示例,我创建了一个简单的索引并添加了一些文档:

PUT /test_index
{
    "settings": {
        "number_of_shards": 1,
        "number_of_replicas": 0
    }
}

POST /test_index/_bulk
{"index":{"_index":"test_index","_type":"doc"}}
{"email": "kar@gmail.com"}
{"index":{"_index":"test_index","_type":"doc"}}
{"email": "xyz@yahoo.com"}
{"index":{"_index":"test_index","_type":"doc"}}
{"email": "somebody@somewhereelse.com"}

然后运行一个简单的匹配查询,得到了预期的结果:

POST /test_index/_search
{
   "query": {
      "match": {
         "email": "kar@gmail.com,xyz@yahoo.com"
      }
   }
}
...
{
   "took": 2,
   "timed_out": false,
   "_shards": {
      "total": 1,
      "successful": 1,
      "failed": 0
   },
   "hits": {
      "total": 2,
      "max_score": 0.43920785,
      "hits": [
         {
            "_index": "test_index",
            "_type": "doc",
            "_id": "AhjrGCcXSjW26eNDDYENHA",
            "_score": 0.43920785,
            "_source": {
               "email": "kar@gmail.com"
            }
         },
         {
            "_index": "test_index",
            "_type": "doc",
            "_id": "X7Fk6J1TQMWK5ZccsfBrVA",
            "_score": 0.43920785,
            "_source": {
               "email": "xyz@yahoo.com"
            }
         }
      ]
   }
}

这是我使用的代码(如果您使用的是 ES 1.4,则必须启用 CORS 才能在浏览器中使用该代码):

http://sense.qbox.io/gist/633c2d284979b26406040db90815231ba71513bc