Elastic search disable date detection using RestHighLevelClient

220 views Asked by At

one of JSON fields I'm indexing is string in form "2000-01-01".

Indexing goes ok, but query operation fails with search_phase_execution_exception, reason=all shards failed.

Indexing:

IndexRequest request = new IndexRequest("testIndex");
request.source(jsonObject, XContentType.JSON);
request.type("text");
try (RestHighLevelClient client =         RestClients.create(ClientConfiguration.builder().connectedTo(esHostPort).build()).rest()) {
        client.index(request, RequestOptions.DEFAULT);

}

Query:

SearchSourceBuilder builder = new         SearchSourceBuilder().postFilter(QueryBuilders.multiMatchQuery(queryString, searchFields));
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
mapper.`enter code here`disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);

try (RestHighLevelClient client = RestClients.create(ClientConfiguration.builder().connectedTo(esHostPort).build()).rest()) {
SearchHit[] searchHits = client.search(new     SearchRequest().searchType(SearchType.DFS_QUERY_THEN_FETCH).source(builder),     RequestOptions.DEFAULT).getHits().getHits();
resp = Arrays.stream(searchHits).map(hit -> {
try {
        return mapper.readValue(hit.getSourceAsString(), QueryResponse.class);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    }).collect(Collectors.toList());
}

When I omit date field, all goes well, so it looks related to date detection which I don't know how to disable in RestHighLevelClient.

Thanks, Ernest

0

There are 0 answers