1

我要索引的 JSON 字段之一是格式为“2000-01-01”的字符串。

索引正常,但查询操作因 search_phase_execution_exception 失败,原因=所有分片失败。

索引:

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 中禁用的日期检测有关。

谢谢,欧内斯特

4

0 回答 0