0

I am using the below query builder from my java class

SearchSourceBuilder()
                .query(BoolQueryBuilder()
                        .filter(QueryBuilders
                                .termQuery("cities.id", cityId)))

It's returning me all the properties of the cityId it matches. But I just need the name of the city.

How can I accomplish it ?

1 Answer 1

1

Good start! You simply need to call the fetchSource() method

SearchSourceBuilder()
    .fetchSource(new String[] {"name"}, null)                 <-- add this line
    .query(BoolQueryBuilder()
                 .filter(QueryBuilders
                            .termQuery("cities.id", cityId)))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.