What is the correct method to search for an attribute that is a null
value?
I'm attempting to search across 3 fields:
query_string : {
query : "rootId:123 AND type:discussion AND
parentId:null"
}
Everything returns as expected when I leave off "AND parentId:null".
When I add "AND parentId:null" back to the query string I get an empty
array back.
What is the correct method to search for an attribute that is a null
value?
I'm attempting to search across 3 fields:
query_string : {
query : "rootId:123 AND type:discussion AND
parentId:null"
}
Everything returns as expected when I leave off "AND parentId:null".
When I add "AND parentId:null" back to the query string I get an empty
array back.
There isn't really a way to do it in search engines simply. One way to solve
it is using the already provided ability to define null_value in the
mappings (for example, na for string, or -1 for numbers) and then search
on it. There is another way to solve this using a "field cache" approach
(similar to what is used for sorting and faceting), but its not implemented
in elasticsearch yet.
What is the correct method to search for an attribute that is a null
value?
I'm attempting to search across 3 fields:
query_string : {
query : "rootId:123 AND type:discussion AND
parentId:null"
}
Everything returns as expected when I leave off "AND parentId:null".
When I add "AND parentId:null" back to the query string I get an empty
array back.
Thanks for the reply.
I do not have any mappings set up, so the null value is what's being
stored.
Is it suggested to not store actual null values and implement mappings
instead?
What is the correct method to search for an attribute that is a null
value?
I'm attempting to search across 3 fields:
query_string : {
query : "rootId:123 AND type:discussion AND
parentId:null"
}
Everything returns as expected when I leave off "AND parentId:null".
When I add "AND parentId:null" back to the query string I get an empty
array back.
What is the correct method to search for an attribute that is a null
value?
I'm attempting to search across 3 fields:
query_string : {
query : "rootId:123 AND type:discussion AND
parentId:null"
}
Everything returns as expected when I leave off "AND parentId:null".
When I add "AND parentId:null" back to the query string I get an empty
array back.
What is the correct method to search for an attribute that is a null
value?
I'm attempting to search across 3 fields:
query_string : {
query : "rootId:123 AND type:discussion AND
parentId:null"
}
Everything returns as expected when I leave off "AND parentId:null".
When I add "AND parentId:null" back to the query string I get an empty
array back.
What is the correct method to search for an attribute that is anull
value?
I'm attempting to search across 3 fields:
query_string : {
query: "rootId:123 AND type:discussion AND
parentId:null"
}
Everything returns as expected when I leave off "AND parentId:null".
When I add "AND parentId:null" back to thequerystring I get an empty
array back.
Yea, the below trick would work, but not optimally. I had an idea of
having optimized field cache like existence markers for fields, which should
work better (at the expense of more memory).
What is the correct method to search for an attribute that is
anull
value?
I'm attempting to search across 3 fields:
query_string : {
query: "rootId:123 AND type:discussion AND
parentId:null"
}
Everything returns as expected when I leave off "AND
parentId:null".
When I add "AND parentId:null" back to thequerystring I get an
empty
array back.
However, afterwards, I discovered this syntax:
(-companynames:[* TO *])
Hi,
Sorry to revive a dead thread but could you explain what you mean by this syntax? I tried using it as a query string and then I thought maybe a range query but neither of them retrieved the results I expected.
Hey,
No prob reviving the dead from my perspective
field:[* TO *]
Should return all the docs that have "field" populated. Negating it
should yield the negative set:
-companynames:[* TO *]
In pure Lucene purely negative queries don't work as the negative set
must be removed by something. So in Lucene syntax, it'd look like:
(-field:[* TO *] AND :)
Kimchy was clever enough to detect pure negatives in ES and do this
implicitly in some cases. Here are more details on when it isn't
automatically handled:
However, afterwards, I discovered this syntax:
(-companynames:[* TO *])
Hi,
Sorry to revive a dead thread but could you explain what you mean by this
syntax? I tried using it as a query string and then I thought maybe a range
query but neither of them retrieved the results I expected.
Hey,
No prob reviving the dead from my perspective
field:[* TO *]
Should return all the docs that have "field" populated. Negating it
should yield the negative set:
-companynames:[* TO *]
In pure Lucene purely negative queries don't work as the negative set
must be removed by something. So in Lucene syntax, it'd look like:
(-field:[* TO *] AND :)
Kimchy was clever enough to detect pure negatives in ES and do this
implicitly in some cases. Here are more details on when it isn't
automatically handled: Issues · elastic/elasticsearch · GitHub
However, afterwards, I discovered this syntax:
(-companynames:[* TO *])
Hi,
Sorry to revive a dead thread but could you explain what you mean by this
syntax? I tried using it as a query string and then I thought maybe a
range
query but neither of them retrieved the results I expected.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.