2016-01-31 3 views
0

Вот мое отображение:Elasticsearch: Geo Расстояние Запрос Ошибки

$ curl -XGET http://localhost:9200/test-index/dev/_mapping?pretty 
{ 
    "test-index" : { 
    "mappings" : { 
     "dev" : { 
     "properties" : { 
      "Coordinates" : { 
      "type" : "double" 
      }, 
      "DisplayName" : { 
      "type" : "string" 
      }, 
      "Location" : { 
      "type" : "string" 
      }, 
      "RawLocation" : { 
      "type" : "string" 
      }, 
      "Reputation" : { 
      "type" : "string" 
      } 
     } 
     } 
    } 
    } 
} 

Моя цель состоит в том, чтобы запустить гео расстояние запроса по координатам.

Я использую эту координату формат:

"location": [ -73.983, 40.719 ] 

Вот несколько результатов:

$ curl -XGET http://localhost:9200/test-index/dev/_search?pretty 
... 
{ 
     "_index" : "test-index", 
     "_type" : "dev", 
     "_id" : "Arindam Nayak", 
     "_score" : 1.0, 
     "_source":{"RawLocation": "Pune, India", "Reputation": "101", "DisplayName": "Arindam Nayak", "Location": "Pune, Maharashtra 411001, India", "Coordinates": [73.8567437, 18.5204303]} 
}, 
... 

Я перепробовал много способов, чтобы получить список хитов со всего координатой, но безрезультатно:

$ curl -XGET http://localhost:9200/test-index/dev/_search -d ' 
{   
"filter" : { 
     "geo_distance" : { 
     "distance" : "20km", 
        “Coordinates : { 
         "lat" : 40.00, 
         "lon" : 9.00 
        } 
       } 
      } 
     } 
' 

Вот печальный результат:

"error":"SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[6W3CA5U5TqStabDolHcIng][test-index][0]: SearchParseException[[test-index][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [\n{\n\"filter\" : {\n  \"geo_distance\" : {\n  \"distance\" : \"20km\",\n     “Coordinates : {\n      \"lat\" : 40.00,\n      \"lon\" : 9.00\n     }\n    }\n   }\n  }\n]]]; nested: QueryParsingException[[test-index] failed to find geo_point field [“Coordinates]]; }{[6W3CA5U5TqStabDolHcIng][test-index][1]: SearchParseException[[test-index][1]: from[-1],size[-1]: Parse Failure [Failed to parse source [\n{\n\"filter\" : {\n  \"geo_distance\" : {\n  \"distance\" : \"20km\",\n     “Coordinates : {\n      \"lat\" : 40.00,\n      \"lon\" : 9.00\n     }\n    }\n   }\n  }\n]]]; nested: QueryParsingException[[test-index] failed to find geo_point field [“Coordinates]]; }{[6W3CA5U5TqStabDolHcIng][test-index][2]: SearchParseException[[test-index][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [\n{\n\"filter\" : {\n  \"geo_distance\" : {\n  \"distance\" : \"20km\",\n     “Coordinates : {\n      \"lat\" : 40.00,\n      \"lon\" : 9.00\n     }\n    }\n   }\n  }\n]]]; nested: QueryParsingException[[test-index] failed to find geo_point field [“Coordinates]]; }{[6W3CA5U5TqStabDolHcIng][test-index][3]: SearchParseException[[test-index][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [\n{\n\"filter\" : {\n  \"geo_distance\" : {\n  \"distance\" : \"20km\",\n     “Coordinates : {\n      \"lat\" : 40.00,\n      \"lon\" : 9.00\n     }\n    }\n   }\n  }\n]]]; nested: QueryParsingException[[test-index] failed to find geo_point field [“Coordinates]]; }{[6W3CA5U5TqStabDolHcIng][test-index][4]: SearchParseException[[test-index][4]: from[-1],size[-1]: Parse Failure [Failed to parse source [\n{\n\"filter\" : {\n  \"geo_distance\" : {\n  \"distance\" : \"20km\",\n     “Coordinates : {\n      \"lat\" : 40.00,\n      \"lon\" : 9.00\n     }\n    }\n   }\n  }\n]]]; nested: QueryParsingException[[test-index] failed to find geo_point field [“Coordinates]]; }]","status":400} 

Любая помощь?

ответ

1

В статистику ошибок, ES не в состоянии найти Coordinates Поле geo_point. Вам нужно указать поле Coordinates как geo_point, чтобы выполнить любой запрос местоположения.

{ 
    "test-index": { 
    "mappings": { 
     "dev": { 
     "properties": { 
      "Coordinates": { 
      "type": "geo_point" <--- change type from double to geo_point 
      }, 
      "DisplayName": { 
      "type": "string" 
      }, 
      "Location": { 
      "type": "string" 
      }, 
      "RawLocation": { 
      "type": "string" 
      }, 
      "Reputation": { 
      "type": "string" 
      } 
     } 
     } 
    } 
    } 
} 

Поскольку вы используете array format вам нужно вставить координаты в [lon, lat].

Вы должны были бы указать reindex свои данные. После этого ваш запрос будет работать.

Надеюсь, это поможет!

Смежные вопросы