1

I Elasticsearch Einheit im Frühjahr haben wie folgt:GeoPoint mit Spring Data Elasticsearch wird geben Fehler: QueryParsingException [field [Ort] ist kein geo_point Feld]

@Document(indexName = "cities_in", type = "cities") 
public class CityDocument { 

@Id 
private String id; 

@Field(type = FieldType.String) 
private String city; 

@Field(type = FieldType.Object) 
@GeoPointField 
private GeoPoint location; 
} 

aber wenn ich Mapping sehen mit curl curl -s -XGET 'http://localhost:9200/cities_in/cities/_mapping?pretty=1' ich Ausgabe als:

{ 
    "cities_in" : { 
    "mappings" : { 
    "cities" : { 
     "properties" : { 
     "city" : { 
      "type" : "string" 
     }, 
     "id" : { 
     "type" : "string" 
     }, 
     "location" : { 
     "properties" : { 
      "geohash" : { 
      "type" : "string" 
      }, 
      "lat" : { 
      "type" : "double" 
      }, 
      "lon" : { 
      "type" : "double" 
      } 
     } 
     } 
     } 
    } 
    } 
} 
} 

und wenn ich mich unten Fehlermeldung erhalte Abfrage getroffen:

{ 
"error" : { 
"root_cause" : [ { 
    "type" : "query_parsing_exception", 
    "reason" : "No query registered for [geo_point]", 
    "index" : "cities_in", 
    "line" : 1, 
    "col" : 33 
} ], 
"type" : "search_phase_execution_exception", 
"reason" : "all shards failed", 
"phase" : "query", 
"grouped" : true, 
"failed_shards" : [ { 
    "shard" : 0, 
    "index" : "cities_in", 
    "node" : "4jGBH3m4SkqNnBwC196hTw", 
    "reason" : { 
    "type" : "query_parsing_exception", 
    "reason" : "No query registered for [geo_point]", 
    "index" : "cities_in", 
    "line" : 1, 
    "col" : 33 
    } 
} ] 
    }, 
    "status" : 400 
} 

Warum ist der Standorttyp nicht geo_point? Wie man Geopoint mit Sprin verwaltet?

Antwort

3

Wenn Sie Frühling verwenden, stellen Sie sicher, dass thath Sie verwenden GeoPoint von Frühling

org.springframework .data.elasticsearch.core.geo.GeoPoint

2

Das Problem ist, dass FieldType.Object Felder vor @GeoPointField von Spring Data MapperBuilder verarbeitet werden.

So müssen Sie einfach die @Field(type = FieldType.Object) Anmerkung entfernen und wie dies Ihr location Feld deklarieren:

@GeoPointField 
private GeoPoint location; 
+0

Noch funktioniert seine Feder nicht als Feldtyp "geo_point". Wenn ich Mapping mit curl hinzufüge und dann Daten aus dem Frühjahr hinzufüge/lade, funktioniert es. Kann sein, dass der Frühling den Feldtyp "geo_point" nicht unterstützt –

+0

Welche Version von Spring Data verwenden Sie? Haben Sie den Index vor dem Neustart Ihrer Spring App gelöscht? – Val

+0

Vielen Dank, es funktioniert jetzt. Ich habe die GeoPoint-Klasse "org.elasticsearch.common.geo.GeoPoint" anstelle von "org.springframework.data.elasticsearch.core.geo.GeoPoint" verwendet. –

Verwandte Themen