elasticsearch - Multiple should queries with must query -


i building query elastic 5 (using nest in .net), trying achive result:

must have value1 , value 2

should have value3 or value 4

and should have value5 or value6

here query:

    {   "query": {     "bool": {       "must": [         {           "match": {             "code": {               "query": "value1"             }           }         },         {           "match": {             "code": {               "query": "value2"             }           }         }       ],       "should": [         {           "match": {             "code": {               "query": "value3"             }           }         },         {           "match": {             "code": {               "query": "value4"             }           }         }         ],         "should": [         {           "match": {             "code": {               "query": "value5"             }           }         },         {           "match": {             "code": {               "query": "value6"             }           }         }       ],       "minimum_should_match": 1     }   } } 

i dont desired answer (for example dont have anywhere value 5 , value 6 still getting results)

thank you

then need this:

{   "query": {     "bool": {       "must": [         {           "match": {             "code": {               "query": "value1"             }           }         },         {           "match": {             "code": {               "query": "value2"             }           }         },         {           "bool": {             "minimum_should_match": 1,             "should": [               {                 "match": {                   "code": {                     "query": "value3"                   }                 }               },               {                 "match": {                   "code": {                     "query": "value4"                   }                 }               }             ]           }         },         {           "bool": {             "minimum_should_match": 1,             "should": [               {                 "match": {                   "code": {                     "query": "value5"                   }                 }               },               {                 "match": {                   "code": {                     "query": "value6"                   }                 }               }             ]           }         }       ]     }   } } 

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -