firebase - Strange output query Elastic Search -


i started using elastic search. i've got set-up correctly. i'm using firebase + flashlight + elastic search.

in front-end i'm building queries based on different search params. insert them node in firebase /search/requests/. flashlight pick , putting response /search/response, works charm!

however, i'm not sure how write queries properly. i'm getting strange results when i'm trying combine 2 must match queries. i'm using query dsl.

my documents in elastic search under deliverables/doc having following scheme.

... {   "createdby" : "admin@xx.org",   "createdon" : 1501200000000,   "deadline" : 1508716800000,   "description" : {     "value" : "dummy description"   },   "key" : "<fbkey>",    "programmes" : [ {     "code" : "95000",     "name" : "test programme",     "programyear" : 2017   } ],   "projects" : [ {     "projectcode" : "113200",     "projectname" : "test project",     "projectyear" : 2017   } ],   "reportingyear" : 2017,   "status" : "open",   "type" : "writing",   "updatedby" : "admin@xx.org",   "updatedon" : 1501200000000, }, ... 

my query has following structure.

{    "query": {     "bool": {       "must": [         {           "match": {             "createdby": "xx@company.org"           },           "match": {             "programmes.code": "95000"           }         }       ]     }   } } 

in output i'm getting documents don't have 2 fields? have low score well. normal?

my mapping, automatically created using flashlight

enter image description here

update 1

i tried query, still gives me strange results not filtering on both fields:

   {    "query": {       "bool": {          "filter": {             "bool": {                "must": [                   {                      "match": {                         "programmes.code": "890000"                      }                   },                   {                      "match": {                         "createdby": "admin@xx.org"                      }                   }                ]             }          }       }    } } 

the must clause used in bool query executed in query context(all documents returned in decreasing order of score) , contributes score. see link

if want executed filter, use following query:

{   "query": {     "bool": {       "filter": {         "bool": {           "must": [             {               "match": {                 "createdby": "xx@company.org"               }             },             {               "match": {                 "programmes.code": "95000"               }             }           ]         }       }     }   } } 

Comments