Null/blank search

Hi Team,

I have a query regarding null and blank ("") search. I want to get all the documents where a particular field is not blank ("") or not null. For e. g. i have field named field1, i want to get all those docs where field1 !=null or field1 !="".

I have specified keyword analyzer on field1 in mapping file and injected some data. suppose we query like following for blank values (we are looking for docs where field1=!"") -

"query" : {
"query_string" : {
"query" : "- field1:""",
"default_operator" : "and",
"analyzer" : "search_analyzer",
"allow_leading_wildcard" : false,
"analyze_wildcard" : true
}
}

It gives us back those docs where field1 is not blank but it also giving us back those docs too where field1 is not present i. e. field1 is null.

Please suggest is there any way in ES to form a query string which can filter for null too.

Thanks

The better approach probably is to use the 'exists' and 'missing' filters
within a filtered query:

On Monday, April 9, 2012 1:39:13 PM UTC+2, Kranti wrote:

Hi Team,

I have a query regarding null and blank ("") search. I want to get all the
documents where a particular field is not blank ("") or not null. For e. g.
i have field named field1, i want to get all those docs where field1 !=null
or field1 !="".

I have specified keyword analyzer on field1 in mapping file and injected
some data. suppose we query like following for blank values (we are looking
for docs where field1=!"") -

"query" : {
"query_string" : {
"query" : "- field1:""",
"default_operator" : "and",
"analyzer" : "search_analyzer",
"allow_leading_wildcard" : false,
"analyze_wildcard" : true
}
}

It gives us back those docs where field1 is not blank but it also giving us
back those docs too where field1 is not present i. e. field1 is null.

Please suggest is there any way in ES to form a query string which can
filter for null too.

Thanks

--
View this message in context:
http://elasticsearch-users.115913.n3.nabble.com/null-blank-search-tp3896591p3896591.html
Sent from the Elasticsearch Users mailing list archive at Nabble.com.