My exists filter is not working for the array stucture. The query is as
follows:
{
"query": {
"filtered": {
"query": {
"term": {
"subtype": {
"value": "izapregistereduser",
"boost": 1
}
}
},
"filter": {
"exists": {
"field": "posts"
}
}
}
}
}
Here the posts is a nested array stucture,but if i run the following query,
its giving the results:
What si posts? Is it an actual field that gets indexed? Can you gist an example of the data you index?
On Tuesday, January 31, 2012 at 2:59 PM, Narinder Kaur wrote:
Hi guys
My exists filter is not working for the array stucture. The query is as follows:
{
"query": {
"filtered": {
"query": {
"term": {
"subtype": {
"value": "izapregistereduser",
"boost": 1
}
}
},
"filter": {
"exists": {
"field": "posts"
}
}
}
}
}
Here the posts is a nested array stucture,but if i run the following query, its giving the results:
Its an nested array structure, that has some ids and related
attributes to those ids. and I wanted to get only those documents which has
this posts or non-empty posts . You can have an idea about its structure
from the following example.
You can only do exists on a specific actual "core" field that has data, not on a json object, for example, on posts.id
On Wednesday, February 1, 2012 at 8:01 AM, Narinder Kaur wrote:
Its an nested array structure, that has some ids and related attributes to those ids. and I wanted to get only those documents which has this posts or non-empty posts . You can have an idea about its structure from the following example.
I don't mean to hijack this thread, but I think I'm trying to achieve the
same as the OP, but I have no alternatives other than to check whether or
not a json object exists. For example the structure:
[
{
"User" : "Marcus",
"Content" : {
"Content" : "This is a post",
"Title" : "The title of this post"
},
"Media" : {
"Header" : "http://.../images/one.jpg"
}
},
{
"User" : "Marcus",
"Content" : {
"Content" : "This is another post, but without a header",
"Title" : "The title of this other post"
}
}
]
These objects are representative of the problem, but are not my structures.
I need to be able to find all documents with a "Media" object.
As long as I can retrieve the objects in the above structure I am open to
adding an array of the keys present as long as I can remove it before
retrieval.
One workaround I was pondering was to use the filter on one of the core
fields in the "Media" object, but the keys are subject to change so there
isn't a single key which is present for all "Media" objects.
Is there a technical reason why the exists filter isn't implemented on
objects?
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.