简体   繁体   中英

Java API for filter_path in elastic search

I need to reduce the response size of elastic search query, So I found one way to use Response Filtering through filter_path parameter in URL.

GET testindex-2016.04.14/_search?filter_path=aggregations.testAggs.buckets 

Below is the link: https://www.elastic.co/guide/en/elasticsearch/reference/2.3/common-options.html#_response_filtering

But I couldn't find any way to implement response filtering in Java API, While googling, I have also seen one FilterPath.java class in elastic search, but I couldn't find any example of it. Even I am not sure whether this class can be used for this purpose or not.

Please suggest me any way to implement response filtering in Java. Thanks

If you only want some fields in the response you should specify them in your query like this:

 myquery = {
    "_source": {
        "includes": ["user.screen_name", "entities.user_mentions.screen_name"]},
    "query": {
        "bool": {....

You can also use "exclude".

Here is the documentation: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-source-filtering.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM