0
Elasticsearch版本:爲什麼這個percolator查詢無效?
$ curl http://localhost:8086/?pretty
{
"status" : 200,
"name" : "Selene",
"cluster_name" : "elasticsearch",
"version" : {
"number" : "1.5.0",
"build_hash" : "544816042d40151d3ce4ba4f95399d7860dc2e92",
"build_timestamp" : "2015-03-23T14:30:58Z",
"build_snapshot" : false,
"lucene_version" : "4.10.4"
},
"tagline" : "You Know, for Search"
}
有了這個映射:
$ curl http://localhost:8086/watches/watches/_mapping?pretty
{
"watches" : {
"mappings" : {
"watches" : {
"properties" : {
"location" : {
"type" : "geo_shape",
"tree_levels" : 5
},
"name" : {
"type" : "string"
}
}
}
}
}
}
常規查詢是好的:
$ curl -XGET -d '
> {
> "query": {
> "filtered": {
> "filter": {
> "and": [
> {
> "geo_shape": {
> "location": {
> "shape": {
> "type": "envelope",
> "coordinates": [[-180, 90], [180, -90]]
> }
> }
> }
> }
> ]
> }
> }
> }
> }
> ' 'http://localhost:8086/watches/watches/_search?pretty'
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [ {
"_index" : "watches",
"_type" : "watches",
"_id" : "berlin",
"_score" : 1.0,
"_source":
{
"name": "Wind & Wetter, Berlin, Germany",
"location": {
"type": "Point",
"coordinates": [13.400544, 52.530286]
}
}
} ]
}
}
認沽註冊一個類似過濾器查詢失敗:
$ curl -XPUT -d '
> {
> "query": {
> "filtered": {
> "filter": {
> "and": [
> {
> "geo_shape": {
> "location": {
> "shape": {
> "type": "envelope",
> "coordinates": [[-180, 90], [180, -90]]
> }
> }
> }
> }
> ]
> }
> }
> }
> }
> ' 'http://localhost:8086/watches/.percolator/mypercolatorquery?pretty'
{
"error" : "PercolatorException[[watches] failed to parse query [mypercolatorquery]]; nested: QueryParsingException[[watches] Field [location] is not a geo_shape]; ",
"status" : 500
}
爲什麼以及如何使用過濾器註冊我的查詢?