i am trying to convert below ES query which is working in console to Java Code
{
"query": {
"bool": {
"must": [
{
"match": {
"ID.keyword": "1234457654"
}
},
{
"bool": {
"should": [
{"match": {
"stepName.keyword": "STEP1"
}},
{"match": {
"stepName.keyword": "STEP2"
}}
]
}
}
]
}
}
}
Java code which i tried
QueryBuilder qb = QueryBuilders.boolQuery().
must(QueryBuilders.matchQuery("ID.keyword", transformedDataDTO.getID()).operator(Operator.AND)).
should(QueryBuilders.matchQuery("stepName.keyword", transformedDataDTO.getStepName()))
.should(QueryBuilders.matchQuery("stepName.keyword", MigrationStatusEnum.getPreviousData(transformedDataDTO.getStepName())));
instead of returning data matching to step1 or step2 it returns all the data
Please suggest what is missing in above java code or how to fix it.