Conditionally retrieve a field in source

Hi, I have a special requirement that I don't know how to do it. Help much appreciated.

I have a type that has field indicating if another field should be revealed. For example, a field is ifRevealAge. If true, than query result for the document should include the age field. If false, than age field should not be included in return result.

Is it possible to do it by a query condition or script?

If not, how to do it via java client api? I know the method toXContent(XContentBuilder builder, ToXContent.Params params) is supposed to do so but I can't find any documentation or references for how to use the method for filtering. The api documentation is just too concise.

Many thanks.

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