Source filtering with Java High Level Rest Client

How can you perform source filtering with the Java High Level Rest Client

For example if I'm doing a reindex request, I would do something like the following to only include the fields which are relevant to me.

POST _reindex
{
    "source": {
        "index": "twitter",
        "_source": ["user", "_doc"]
    },
    "dest": {
        "index": "new_twitter"
    }
}

Is it even possible to achieve the same through the Java Client's ReindexRequest?

ReindexRequest reindexRequest = new ReindexRequest();
reindexRequest.setSourceIndices("twitter");
reindexRequest.setDestIndex("new_twitter");
// how can you set the fields to include?

Hey,

you can change the underlying search request, that is used within the reindex request

req.getSearchRequest().source().fetchSource(...)

hope this helps.

--Alex

Yes, that is exactly what I needed.

Cheers

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.