How does must work's for multiple query with in array and in filter if there is null value(for query) then automatically remove that query

{
	"query": {
    	"bool":{
    		"must": [ {"match" : { "userid" : "001" } }, {"query_string" : {"fields":["searchbar_content"],"query" : "*"} } ],
    		"filter":[
		    			{ "terms" : { "tag" : ["tag yesterday"] } },
		    			{ "range": { "craetedon":{ "gte":"now-12M" ,"lt":"now" } } } 
    			     ]
    	}
    }
}

let suppose there are multiple record correspond to userid.

userid is written first and string query second in must array.

First case :
does must first search for all record correspond to userid and then find filter out query result in above case. or userid and query string both take together and find result.

Second Case :
let suppose user does not give any tag value or createdon value or both

    		"filter":[
		    			{ "terms" : { "tag" : ["null"] } },
		    			{ "range": { "craetedon":{ "gte":"now-12M" ,"lt":"now" } } } 
    			     ]

then filter automatically remove this query and filter like(after null)

   		"filter":[
		    			{ "range": { "craetedon":{ "gte":"now-12M" ,"lt":"now" } } } 
    			     ]

Second case for filter :

   		"filter":[
		    			{ "terms" : { "tag" : ["tagg"] } },
		    			{ "range": { "craetedon": {null} } } 
    			     ]
    		"filter":[
		    			{ "terms" : { "tag" : ["tagg"] } }
    			     ]

Third case for filter:
if userid and created are null then no filter

{
	"query": {
    	"bool":{
    		"must": [ {"match" : { "userid" : "001" } }, {"query_string" : {"fields":["searchbar_content"],"query" : "*"} } ]
}}}

image
i want to develop gmail like search one search bar (string query)
and filter if user left blank field then this field should be remove as i said earlier.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.