未注册查询[match]



我正在研究ElasticSearch Server书中的一些示例,并试图编写一个简单的匹配查询

{ 
  "query" : { 
    "match" : {
        "displayname" : "john smith"
    }
  }
}

这给了我错误:

{"error":"SearchPhaseExecutionException[Failed to execute phase [query],      
....
SearchParseException[[scripts][4]: from[-1],size[-1]: Parse Failure [Failed to parse source 
....
QueryParsingException[[kb.cgi] No query registered for [match]]; }

我也试过

{ 
    "match" : {
    "displayname" : "john smith"
    }
}

按照http://www.elasticsearch.org/guide/reference/query-dsl/match-query/

上的示例编辑:我认为我使用的远程服务器不是最新的0.20.5版本,因为使用"文本"而不是"匹配"似乎允许查询工作

我在这里看到一个类似的问题:http://elasticsearch-users.115913.n3.nabble.com/Character-escaping-td4025802.html

我使用的远程服务器似乎不是最新的0.20.5版本的ElasticSearch,因此不支持"匹配"查询-而是"文本",它的工作

在看到这里报告的类似问题后,我得出了这个结论:http://elasticsearch-users.115913.n3.nabble.com/Character-escaping-td4025802.html

您的第一个查询看起来不错,但也许您在请求中使用的方式不正确。下面是一个完整的例子:

curl -XDELETE localhost:9200/test-idx
curl -XPUT localhost:9200/test-idx -d '{
    "settings": {
        "index": {
            "number_of_shards": 1,
            "number_of_replicas": 0
        }
    },
    "mappings": {
        "doc": {
            "properties": {
                "name": {
                    "type": "string", "index": "analyzed"
                 }
            }
        }
    }
}
'
curl -XPUT localhost:9200/test-idx/doc/1 -d '{
    "name": "John Smith"
}'
curl -XPOST localhost:9200/test-idx/_refresh
echo
curl "localhost:9200/test-idx/_search?pretty=true" -d '{
    "query": {
        "match" : {
            "name" : "john smith"
        }
    }
}
'
echo

最新更新