Equivalent JAVA code for the below query

Please help me with the equivalent java code to this search

GET my_index/_search { "query": { "bool": { "must": { "nested": { "path": "workexperience", "query": { "terms": { "workexperience.title": [ "1" ] } } } } } } }

Please format your code, logs or configuration files using </> icon as explained in this guide and not the citation button. It will make your post more readable.

Or use markdown style like:

```
CODE
```

This is the icon to use if you are not using markdown format:

There's a live preview panel for exactly this reasons.

Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.
Please update your post.

Also what did you try so far?

Hi dadoonet,

I have formatted as per your suggestion.

I was able to solve the problem after some googling thank you.

May be share your solution here?

QueryBuilders.boolQuery()
                    .must(QueryBuilders.nestedQuery("title",
                            QueryBuilders.termsQuery(
                                    "title" + "." + "workexperience",
                                    List.of("1"),
                            ScoreMode.Avg));

The above is the equivalent Java code, which is working fine for me.

1 Like

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