elasticsearch使用resthighlevelclient禁用日期检测

wbrvyc0a  于 2021-06-10  发布在  ElasticSearch
关注(0)|答案(0)|浏览(248)

我索引的json字段之一是格式为“2000-01-01”的字符串。
索引正常,但查询操作失败,搜索\阶段\执行\异常,原因=所有碎片失败。
索引:

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);

}
查询:

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());
}

当我省略日期字段时,一切都很顺利,所以它看起来与日期检测有关,我不知道如何在resthighlevelclient中禁用它。
谢谢,欧内斯特

暂无答案!

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

相关问题