我无法找到如何从弹性搜索中的响应中排除字段。
这是我的要求:
SearchResponse response = client
.prepareSearch("_all")
.setSearchType(SearchType.DFS_QUERY_AND_FETCH)
.setQuery(
QueryBuilders.boolQuery()
.should(matchQuery("location.endpoint", "activemq://*****"))
.should(matchQuery("location.endpoint", "http://localhost/proxy/etatest/soap/inbound/"))
.should(fuzzyLikeThisQuery("location.endpoint").likeText("//****"))
.should(matchQuery("status", "RESPONSE"))
.should(matchQuery("status", "RESPONSE_WITH_FAILURES"))
.minimumNumberShouldMatch(1)
)
.setPostFilter(FilterBuilders.boolFilter()
.must(existsFilter("exchange.wfm_idocNumber"))
.must(rangeFilter("@timestamp").from("2015-01-08T14:20:00.197+01:00").to("2015-01-08T14:21:00.197+01:00"))
)
.execute()
.actionGet();
谢谢
答案 0 :(得分:1)
尝试此操作,将要排除的字段放在排除数组中。
String[] includes = {};
String[] excludes = {};
SearchResponse response = client
.prepareSearch("_all")
.setSearchType(SearchType.DFS_QUERY_AND_FETCH)
.setQuery(
QueryBuilders.boolQuery()
.should(matchQuery("location.endpoint", "activemq://*****"))
.should(matchQuery("location.endpoint", "http://localhost/proxy/etatest/soap/inbound/"))
.should(fuzzyLikeThisQuery("location.endpoint").likeText("//****"))
.should(matchQuery("status", "RESPONSE"))
.should(matchQuery("status", "RESPONSE_WITH_FAILURES"))
.minimumNumberShouldMatch(1)
)
.setPostFilter(FilterBuilders.boolFilter()
.must(existsFilter("exchange.wfm_idocNumber"))
.must(rangeFilter("@timestamp").from("2015-01-08T14:20:00.197+01:00").to("2015-01-08T14:21:00.197+01:00"))
)
.setFetchSource(includes, excludes)
.execute()
.actionGet();