I am new to elasticSearch, and I am trying to consult the documents that have a match with a specific point on the map, I am using the GeoPoint object, and I need to make a query that returns all the "geozones" that contain this period, but I am somewhat confused with the elasticsearch queries.
I still do not understand correctly the structure that my document must have in order to perform these actions, here I leave the class of the document I am calling
@Data
@Document(indexName = "geozona")
public class GeozonaElasticDTO {
@Id
@Field(type = FieldType.Long)
private long id;
@Field(type = FieldType.Text)
private UUID uuid;
@Field(type = FieldType.Text)
private String nombre;
@Field(type = FieldType.Text)
private String descripcion;
private List<UUID> etiquetas;
private List<UUID> lugares;
private List<UUID> geozonaLimiteVelocidad;
@Field(type = FieldType.Text)
private EnumTipoGeozona tipoGeozona;
@Field(type = FieldType.Double)
private Double radio;
@Field(type = FieldType.Text)
private String pathEncode;
@Field(type = FieldType.Object)
@GeoPointField
private List<GeoPoint> points;
@Field(type = FieldType.Double)
private double puntoDeReferenciaLatitud;
@Field(type = FieldType.Double)
private double puntoDeReferenciaLongitud;
@Field(type = FieldType.Integer)
private int limiteDeOrientacionGradoInicio;
@Field(type = FieldType.Integer)
private int limiteDeOrientacionGradoTermino;
@Field(type = FieldType.Integer)
private Integer ancho;
@Field(type = FieldType.Boolean)
private boolean eliminado;
@Field(type = FieldType.Date, format = DateFormat.custom, pattern = "uuuu-MM-dd'T'HH:mm:ssZ")
private ZonedDateTime fechaCreacion;
@Field(type = FieldType.Date, format = DateFormat.custom, pattern = "uuuu-MM-dd'T'HH:mm:ssZ")
private ZonedDateTime fechaActualizacion;
@Field(type = FieldType.Integer)
private int version;
}
this is the structure of my class in elastic server
"geozona": {
"aliases": {},
"mappings": {
"properties": {
"_class": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"ancho": {
"type": "integer"
},
"descripcion": {
"type": "text"
},
"eliminado": {
"type": "boolean"
},
"etiquetas": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"fechaActualizacion": {
"type": "date",
"format": "uuuu-MM-dd'T'HH:mm:ssZ"
},
"fechaCreacion": {
"type": "date",
"format": "uuuu-MM-dd'T'HH:mm:ssZ"
},
"geozonaLimiteVelocidad": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"id": {
"type": "keyword"
},
"limiteDeOrientacionGradoInicio": {
"type": "integer"
},
"limiteDeOrientacionGradoTermino": {
"type": "integer"
},
"lugares": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"nombre": {
"type": "text"
},
"pathEncode": {
"type": "text"
},
"points": {
"type": "geo_point"
},
"puntoDeReferenciaLatitud": {
"type": "double"
},
"puntoDeReferenciaLongitud": {
"type": "double"
},
"radio": {
"type": "double"
},
"tipoGeozona": {
"type": "text"
},
"uuid": {
"type": "text"
},
"version": {
"type": "integer"
}
}
},
"settings": {
"index": {
"refresh_interval": "1s",
"number_of_shards": "1",
"provided_name": "geozona",
"creation_date": "1609949683125",
"store": {
"type": "fs"
},
"number_of_replicas": "1",
"uuid": "m-y7Qa5wSwGmDA3TVm4HkA",
"version": {
"created": "7090299"
}
}
}
}
}
If someone can guide me on how to start working correctly the coincidence of geolocation points with elastic, it would help me a lot.
question from:
https://stackoverflow.com/questions/65600339/elasticsearch-how-to-find-a-match-with-a-geolocation-point-with-elasticsearch