"Must" query like AND condition. Your query look like : "keywords" field
must match "Holi" AND "symptom" field must match "Holi". If you want OR
condition, use "Should" query instead.
On Monday, March 9, 2015 at 2:13:26 PM UTC+7, Vijayakumari B N wrote:
>
> 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/6e4b0a3d-7d06-4e07-a9bf-4debb879f275%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.