2017-02-23 3 views
1

ich verwende feder Boot 1.5.1 mit Elasticsearch 2.3.5 (für Mahout Recommender-System), so ich habe ein Problem mit Mapping:Bad Mapping mit @GeoPointField Elasticsearch

@GeoPointField 
private GeoPoint location; 

Von Paket:

org.springframework.data.elasticsearch.core.geo; 

Also, von localhost:9200/.../.../_mapping?pretty=1 ich habe:

location: { 
    properties: { 
    lat: { 
    type: "double" 
    }, 
    lon: { 
    type: "double" 
    } 
    } 
} 

Aber ich will geo_point Geben Sie das Standortfeld ein.

Als Ergebnis, wenn ich versuche:

CriteriaQuery query = new CriteriaQuery(new Criteria("location").within(startLocation, range)); 

ich habe:

QueryParsingException[failed to find geo_point field [location]] 

Hat jemand die Lösung weiß? Thx

+0

Ich habe die gleiche Konfiguration und hatte das gleiche Problem. Ich habe alle ElasticSearch-Dateien entfernt und als ich dann die Entitäten erstellt habe, haben sie die korrekte Zuordnung erhalten. – Aerus

Antwort

0

Das Problem ist mit Ihrem Mapping. Es sollte geo_point Typ sein. z.B.
Sie tun können, es mit curl PUT

curl -XPUT 'http://localhost:9200/your_index/_mapping/your_type' -d ' 
{ 
    "your_type" : { 
     "properties" : { 

      "phone": { 
     "type": "string", "index": "not_analyzed" 
    }, 
    "webSite": { 
     "type": "string", "index": "not_analyzed" 
    } 
    "location": { 
     {"type": "geo_point"}    
    } 
    } 
} 
' 

Wenn die Daten zu speichern, können Sie tun:

"location":{ 
    "lat":11.68036, 
    "lon":-93.3103 
} 
+0

Ok :) @Hosar, ich weiß, dass das Problem ist meine Zuordnung, aber wie kann ich es mit der Verwendung von Spring Data Elasticsearch lösen? – maystrovyy

+0

Sie können es mit Curl tun, nicht sicher, wie es mit Spring zu tun ist. – Hosar

Verwandte Themen