json - ElasticSearch filtered query with operator AND and OR -


i'm intervening on existing app interacts elasticsearch sever , i'm seeing weird responses, due fact i'm new elastic.

i have indexed item below :

"_id": "59773d268770541557000012",         "_score": 0.03282923,         "_source": {            "_id": "59773d268770541557000012",            "active": null,            "address": "dummy address",            "center_ids": [],            "consultation_site_ids": [],            "coordinates": null,            "created_at": "2017-07-25t14:44:22.270+02:00",            "death_declaration_form_step_id": "56ddb086f0e0103b44000000",            "end_of_pregnancy_form_step_id": "56c34e63f0e0105e65000000",            "fax": "06.95.40.58.84",            "form_step_ids": [               "55361b215342491667030000",               "5541f16252f131f6a125a375",               "55361ba05342491667040000",               "553610835342491667010000",               "55361d225342491667050000",               "5541f34a52f131f6a125a377"            ],            "hospital_id": "57c004905c5393772c002a62",            "name": "test site d'encronologie",            "phone": "06.95.40.58.84",            "short_name": "test site d'encronologie d'endcronologie",            "sites_union_ids": [],            "state": "active",            "updated_at": "2017-07-25t14:44:22.270+02:00",            "url": "http://www.testurl.com",            "user_ids": [],            "warnings_threshold": null,            "_type": "site 

and querying server query:

 "query":{     "filtered":{        "query":{           "bool":{              "should":[                 {                    "multi_match":{                       "fields":[                          "name^5",                        "name.edge^1",                        "name.full^0.3"                     ],                     "query":"enc",                     "type":"cross_fields"                  }               },               {                    "match":{                       "name":{                          "query":"enc",                        "type":"phrase_prefix",                        "operator":"or"                     }                  }               },               {                    "match":{                       "name":{                          "query":"enc",                        "type":"boolean",                        "boost":5                     }                  }               }            ]         }      },      "filter":{           "and":[              {                 "term":{                    "hospital_id":"57c004905c5393772c002a62"               }            },            {                 "term":{                    "state":"active"               }            }         ]      }   } }} 

which returns nothing (no hits)

and other hand, if change filter operator "and" "or" recieve 1 hit.

i talking "and" on "filter" branch :

    "filter":{               "and":[ 

i realy don't understand how come or works not and?

then again when change query term "enc" "zzz_enc" in query{} of first branch while keeping "or" have 0 matches, though filter condition hospital_id , state true on item.

why filter operator behave ?

thank in advance.


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -