How to use 'exists' filter on no indexed objects/fields


(Han JU) #1

Hi, I have some object type like:

{
'person': {
'properties': {
'age': {'index': 'no', 'type': 'long'},
'name': {'index': 'no', 'type': 'string'}
}
}
}

So in fact these fields are not indexed at all, they are not visible to
filters. But what I want to is to be able to use 'exists' and 'missing'
filters on these fields ('person', 'person.age' or 'person.name').
A simple hack is to add an indexed, boolean field for each no index field,
like:

{
'person': {
'properties': {
'age': {'index': 'no', 'type': 'long'},
'age_exists': {'type': 'boolean'},

      'name': {'index': 'no', 'type': 'string'}
      'name_exists': {'index': 'no', 'type': 'boolean'}
   }
 }

}

And modify my queries that check field existence on these boolean flag
fields.
This works for a few fields like this but now I have plenty of them and it
also complicates my query logic. So dear elasticsearch users, is there a
better solution to this?

Thanks.

--
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/67cc1526-f4a8-4c0b-aaff-a78cf23fca6c%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Binh Ly-2) #2

Other than indexing the field, I can't think of another way.

--
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/cb704734-70ad-4e8b-8595-c3d1e66e7bce%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Han JU) #3

Thanks Binh.

In fact the fields I'm working on are large lists and their only role in
the query part is exists.
Since they are large number lists, my intuition tells me that it's not a
very good idea to include in the index. Am I correct?

在 2014年3月3日星期一UTC+1下午9时43分59秒,Binh Ly写道:

Other than indexing the field, I can't think of another way.

--
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/52e9b9e3-0693-418e-adf5-4294c9698d11%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #4