3
votes

I want to get sort by distance response from elastic search but I have unmapped longitude and latitude values in elastic search hence I am not getting any result using below query.

How can i get "ignore_unmapped":"true" in sort like below query

I have tried using GeoDistanceSortBuilder and there is no method to set ignore_unmapped. I cannot find any other class to build sort query

{
geoSort = geoDistanceSort(LOCATION_POINT_HOLDER, 0, 0).unit(DistanceUnit.KILOMETERS).order(SortOrder.DESC);
}

"type": "illegal_argument_exception", "reason": "failed to find mapper for [location] for geo distance based sort"

I am getting this error without setting ignore_unmapped:true.

2

2 Answers

0
votes

repalce elasticsearch maven dependency earlier than 6.3.2

<dependency>
    <groupId>org.elasticsearch</groupId>
    <artifactId>elasticsearch</artifactId>
    <version>6.3.0</version>
</dependency>
<dependency>
    <groupId>org.elasticsearch.client</groupId>
    <artifactId>elasticsearch-rest-high-level-client</artifactId>
    <version>6.3.0</version>
    <exclusions>
            <exclusion>
                <artifactId>elasticsearch</artifactId>
                <groupId>org.elasticsearch</groupId>
            </exclusion>
    </exclusions>
</dependency>

or upgrade the version of elasticsearch

0
votes

In 7.2.0 you can set it through unmapped e.g

SortBuilders
 .geoDistanceSort("location", 0.0, 0.0)
 .ignoreUnmapped()