Uncertain how to properly filter when certain fields do not always exist

I am trying to filter based on a field that, on some objects, does not
exist. I was under the impression that ES would match objects that don't
have that field.

Ultimately, I am trying to filter as such:

  • Field A will always exist, and should match on any of tags 1,2,3
  • When it exists, either Field B or C must match any of tags 5,6,7
  • When it exists, Field B must match any of tags 10, 11, 12
  • When it exists, Field B or C must NOT have any of tags 15, 16, 18.

In this case, all my tags are strings. In addition, fields B and C are
inside of another. I am uncertain if that matters.

Essentially, my object is:

{ a: ["some", "tags", "here"],
X : {
B: ["more", "tags", "here"],
C: ["even", "more", "here"]
}
}

Ultimately, I am trying to build a whitelist and blacklist filtering system.

However, when filtering this way, I do not get any results that do not
contain field X.

How do I properly format this filter?

--
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/754097d9-fff7-4773-bac4-54f4fe3e5172%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Following advice I've receivedhttp://stackoverflow.com/questions/21005516/uncertain-how-to-properly-filter-when-certain-fields-do-not-always-existfrom StackOverflow poster Sloan Ahrens, I made a
test http://sense.qbox.io/gist/8f7369e7991db56f7b1592f11245cb8bf6dc933f that
worked on a test index, but not on a main index. However, I was getting
false matches.

I've added my index settings http://sense.qbox.io/gist/a73c74e71df4aca6c58283bca1cde6e6071644dfand
found that somehow, the addition of the relatedProfiles mapping makes it so
that I get false-hits. Can anyone explain why that is?

On Thursday, January 9, 2014 10:17:29 AM UTC-5, Phil Barresi wrote:

I am trying to filter based on a field that, on some objects, does not
exist. I was under the impression that ES would match objects that don't
have that field.

Ultimately, I am trying to filter as such:

  • Field A will always exist, and should match on any of tags 1,2,3
  • When it exists, either Field B or C must match any of tags 5,6,7
  • When it exists, Field B must match any of tags 10, 11, 12
  • When it exists, Field B or C must NOT have any of tags 15, 16, 18.

In this case, all my tags are strings. In addition, fields B and C are
inside of another. I am uncertain if that matters.

Essentially, my object is:

{ a: ["some", "tags", "here"],
X : {
B: ["more", "tags", "here"],
C: ["even", "more", "here"]
}
}

Ultimately, I am trying to build a whitelist and blacklist filtering
system.

However, when filtering this way, I do not get any results that do not
contain field X.

How do I properly format this filter?

--
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/0951fad9-32d5-4ab8-801a-619ab4201030%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.