模糊这样(FLT) - ElasticSearch

时间:2013-08-08 15:04:18

标签: search curl lucene elasticsearch fuzzy-search

我正在努力将FLT应用到我正在构建的原型ES系统中。我已经查看了Elasticsearch网站上的文档,虽然它已经存在,但我似乎无法实现这一点。也许有人可以给我一些关于如何做到这一点的见解。

我似乎无法在网络上的其他地方找到任何关于此功能的例子,但也许我的Google技能今天还没有达到标准。这是我到目前为止设法构建的 -

$ curl -XGET 'http://127.0.0.1:9200/uber/uber/_search?'  -d '{
  "fuzzy_like_this": {
    "fields": [
      "pty_firstname",
      "pty_surname"
    ],
    "like_text": "Nathan Andew",
    "max_query_terms": 12
  }
}'

以下是我在发送请求时从提示中收到的错误消息 -

{
  "error":"SearchPhaseExecutionException[Failed to execute phase [query], total failure;
          shardFailures {[u9HfJxbXRn-8ml19FKBTiA][uber][2]: SearchParseException[[uber][2]: from[-1],size[-1]:
            Parse Failure [Failed to parse source [
              {
                "fuzzy_like_this": {
                "fields": [
                  "pty_firstname",
                  "pty_surname"
                ],
                "like_text": "Nathan Andew",
                "max_query_terms": 12
                }
              }
            ]]]; nested: SearchParseException[[uber][2]: from[-1],size[-1]:
            Parse Failure [No parser for element [fuzzy_like_this]]]; }{[u9HfJxbXRn-8ml19FKBTiA][uber][0]:
          SearchParseException[[uber][0]: from[-1],size[-1]:
            Parse Failure [Failed to parse source [
              {
                "fuzzy_like_this": {
                "fields": [
                  "pty_firstname",
                  "pty_surname"
                ],
                "like_text": "Nathan Andew",
                "max_query_terms": 12
                }
              }
            ]]]; nested: SearchParseException[[uber][0]: from[-1],size[-1]:
            Parse Failure [No parser for element [fuzzy_like_this]]]; }]",
  "status":500
}

1 个答案:

答案 0 :(得分:15)

我认为您缺少查询部分,您需要执行以下操作:

$ curl -XPOST 'http://127.0.0.1:9200/uber/uber/_search?'  -d '
{
  "query" : {
    "fuzzy_like_this" : {
       "fields" : ["pty_firstname", "pty_surname"],
       "like_text" : "Nathan Andew",
       "max_query_terms" : 12
    }
  }
}'