Hi,

I want to build Query for the requirement where i have 3 check-boxes in 
input(For 3 different attributes), i have to search input text matching in 
the selected check-box. 

I want to dynamically build the query if attribute1 is selected search in 
attribute1, if attribute2 is selected search in attribute2  etc..

I am trying to build query, which matches the input text with must in both 
the attributes, it is not returning any results. If i use Multimatch, i am 
able to fetch results.

BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
        
            if (searchIn.contains("keywords")) {
            boolQueryBuilder.must(QueryBuilders.matchQuery("keywords", 
inputText));
            }
            if (searchIn.contains("symptom")) {
            boolQueryBuilder.must(QueryBuilders.matchQuery("symptom", 
inputText));
            }


Match Query :
{
  "bool" : {
    "must" : [ {
      "match" : {
        "keywords" : {
          "query" : "Holi",
          "type" : "boolean"
        }
      }
    }, {
      "match" : {
        "symptom" : {
          "query" : "Holi",
          "type" : "boolean"
        }
      }
    } ]
  }
}

Multimatch query : 
{
  "multi_match" : {
    "query" : "Holi",
    "fields" : [ "keywordsField", "symptomField", "" ]
  }


Can someone please help me.

Thanks,
Vijaya

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/3d4d8dc6-dc5e-428c-87a5-fc893a7d5e59%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to