I'm using elasticsearch with marvel/sense plugin to create index of shapes with dot type and then register geo_distance filter in percolator:
PUT shapes
{
"mappings": {
"dot": {
"properties": {
"location": {
"type": "geo_point",
"fielddata": {
"lat_lon": "true",
"precision": "1cm"
}
}
}
}
}
}
PUT shapes/.percolator/in_sight
{
"filtered" : {
"query" : {
"match_all" : {}
},
"filter" : {
"geo_distance" : {
"distance" : "200km",
"location" : {
"lat" : 40,
"lon" : -70
}
}
}
}
}
this yields the following error:
{
"error": "PercolatorException[[shapes] failed to parse query [in_sight]]; nested: NullPointerException; ",
"status": 500
}
any idea?
Thanks.
答案 0 :(得分:0)
找到了答案,这是关于弹性搜索很难猜到的语法:
#Create mappings for dot and ellipse types
PUT shapes
{
"mappings": {
"dot": {
"properties": {
"tag" : { "type" : "string" },
"location": {
"type": "geo_point",
"fielddata": {
"lat_lon": "true"
}
}
}
},
"ellipse": {
"properties": {
"tag" : { "type" : "string" },
"location": {
"type": "geo_point",
"fielddata": {
"lat_lon": "true"
}
}
}
}
}
}
#Register geo_distance with percolator
PUT shapes/.percolator/in_sight
{
"query": {
"filtered": {
"filter": {
"geo_distance": {
"distance": "250km",
"location": {
"lat": 30,
"lon": 31
}
}
}
}
}
}
#Query doc against percolator.
POST shapes/ellipse/_percolate
{
"doc": {
"tag": "t3",
"location": {
"lat": 30,
"lon": 30
}
}
}