Geodistance sort throws Elasticsearch exception [type=parsing_exception, reason=[_geo_distance] does not support [ignore_unmapped]] Elastic search version 6.3.0

I am searching the index object based on the lat long (geo_point type) for a distance of 999km and I am sorting it on the ascending order.
But I am getting the exception Elasticsearch exception [type=parsing_exception, reason=[_geo_distance] does not support [ignore_unmapped]]
I am using elasticsearch version 6.3.0 alothough the same code is working fine in version 6.4.0. Is there anyway I can make it work in version 6.3.0

Here is the code that is searching and sorting.

	QueryBuilder queryBuilder = boolQuery().filter(
				QueryBuilders
				.geoDistanceQuery(LOCATION)
				.point(Double.parseDouble(latitude),Double.parseDouble(longitude))
				.distance(Double.parseDouble(range), DistanceUnit.KILOMETERS)
			);
	GeoDistanceSortBuilder sortBuilderAsc = SortBuilders.geoDistanceSort("location", new Double(latitude), new Double(longitude))
			.order(SortOrder.ASC)
			.unit(DistanceUnit.KILOMETERS)
			.sortMode(SortMode.MIN);
	SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
	searchSourceBuilder.query(queryBuilder).sort(sortBuilderAsc);
	SearchRequest searchRequest = new SearchRequest(index);
	searchRequest.source(searchSourceBuilder);
	searchRequest.searchType(SearchType.DFS_QUERY_THEN_FETCH);
	SearchResponse response = getClient().search(searchRequest, RequestOptions.DEFAULT);

This is the index mapping

{
  "buildings": {
    "mappings": {
      "esbuilding": {
        "properties": {
          "addressStreet1": {
            "type": "text"
          },
          "addressStreet2": {
            "type": "text"
          },
          "buildingName": {
            "type": "text"
          },
          "city": {
            "type": "text"
          },
          "location": {
            "type": "geo_point"
          },
          "state": {
            "type": "text"
          }
        }
      }
    }
  }
}

Here is the search JSON that is generated from the above Java Code for a given lat long.

{
  "sort" : [
        {
            "_geo_distance" : {
      					"location": [
      						-71.588822,
      						42.333777
      					],
                "order" : "asc",
                "unit" : "km",
                "mode" : "min",
                "distance_type" : "arc",
                "ignore_unmapped": true
            }
        }
    ],
	"query": {
		"bool": {
			"filter": [{
				"geo_distance": {
					"location": [
						-71.588822,
						42.333777
					],
					"distance" : 999000.0,
					"distance_type": "arc",
					"validation_method": "STRICT",
					"ignore_unmapped": false,
					"boost": 1.0
				}
			}],
			"adjust_pure_negative": true,
			"boost": 1.0
		}
	}
}

Stack trace:

org.elasticsearch.ElasticsearchStatusException: Elasticsearch exception [type=parsing_exception, reason=[_geo_distance] does not support [ignore_unmapped]]
	at org.elasticsearch.rest.BytesRestResponse.errorFromXContent(BytesRestResponse.java:177)
	at org.elasticsearch.client.RestHighLevelClient.parseEntity(RestHighLevelClient.java:1406)
	at org.elasticsearch.client.RestHighLevelClient.parseResponseException(RestHighLevelClient.java:1382)
	at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1269)
	at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1231)
	at org.elasticsearch.client.RestHighLevelClient.search(RestHighLevelClient.java:730)
	at com.trimble.engage.search.repository.ElasticSearchRepository.searchByQueryAndSort(ElasticSearchRepository.java:64)

Is there anyway I can remove the field "ignore_unmapped" from the above java code. If I remove the field ignore_unmapped, it is working fine in version 6.3.0

Which client version are you using?
You should may be use the same 6.3 version of the client?

But, I'd recommend upgrading everything to at least 6.8.7.

I have tried different client versions
6.3.0
6.4.0
7.0.0
But all of them giving the same exception.
Are you suggesting to upgrade the elasticsearch to version 6.8.7 or just the libraries?

How did you define the version to use?
Did you check the dependency tree to make sure that versions are exactly what you think they are?

Both

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.