Add an extra flag in ES query to check if a field exists


(rubyprince) #1

Hi all,

Please see
this http://stackoverflow.com/questions/21875375/add-an-extra-flag-in-es-query-to-check-if-a-field-exists

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/8b78d867-a1c6-4cc8-adf6-90e0f66612dd%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Binh Ly) #2

I'd check that the field arranged_retweets exists in your mapping. If it
doesn't exist in the mapping, try to add it. After that, your query should
start returning results regardless of whether the documents indexed have
that field populated or not.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/c3fde18e-6906-486d-b550-a3c99149978d%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(rubyprince) #3

arranged_retweets do exist in the mapping. I have updated the question
(http://stackoverflow.com/questions/21875375/add-an-extra-flag-in-es-query-to-check-if-a-field-exists)
with the mapping

On Wednesday, February 19, 2014 8:21:23 PM UTC+5:30, Binh Ly wrote:

I'd check that the field arranged_retweets exists in your mapping. If it
doesn't exist in the mapping, try to add it. After that, your query should
start returning results regardless of whether the documents indexed have
that field populated or not.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/46ef1343-a9fb-4d6d-a842-ce52dc42a059%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Binh Ly) #4

I see, looks like it's an object so you'd probably need to check down to
the leaf level, like for example:

doc["arranged_retweets.author_gender"].isEmpty() ||
doc["arranged_retweets.author_link"].isEmpty()

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/8831fe76-253d-41f4-bb21-62a98f4e999c%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(rubyprince) #5

Hi, many thanks for the pointer. I didnt try the code you mentioned, but
changed my code like this:

"script": "!doc['arranged_retweets.author_gender'].empty"

This worked for me. Thank you very much for your help.

On Wednesday, February 19, 2014 9:52:54 PM UTC+5:30, Binh Ly wrote:

I see, looks like it's an object so you'd probably need to check down to
the leaf level, like for example:

doc["arranged_retweets.author_gender"].isEmpty() ||
doc["arranged_retweets.author_link"].isEmpty()

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/c68ca04d-acf8-4cda-8638-d118a088d1c5%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #6