Reputation: 87
I can't find how to exclude fields from a response in elastic search.
here's my request:
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();
Thank you
Upvotes: 1
Views: 3757
Reputation: 458
Try this, put the fields you want to exclude in the exclude array.
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();
Upvotes: 2