2015-04-07 107 views
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 
} 

为什么以及如何使用过滤器注册我的查询?

回答