elasticsearch-如何使用java中的elasticsearch查找与地理位置点匹配的项

8aqjt8rx  于 2021-06-26  发布在  Java
关注(0)|答案(0)|浏览(309)

我是elasticsearch的新手,我正在尝试查阅与Map上特定点匹配的文档,我正在使用geopoint对象,我需要进行一个查询,返回包含此句点的所有“geozones”,但我对elasticsearch查询有些困惑。
为了执行这些操作,我仍然不能正确理解文档必须具有的结构,这里我将调用的文档的类留在这里

@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;
}

这是弹性服务器中我的类的结构

"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"
                }
            }
        }
    }
}

如果有人能指导我如何开始正确的工作-地理定位点与弹性的重合,这将对我有很大帮助。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题