Question about Missing filter on nested fields


(alheim) #1

Hello,

Imagine that we have a nested field adress : adress.street, adress.zipCode
I cannot use a missing filter on adress :
{
"query": {
"constant_score": {
"filter": {
"missing": {
"field": "adress"
}
}
}
}
}

nor on sub-fields :
{
"query": {
"constant_score": {
"filter": {
"missing": {
"field": "adress.zipCode"
}
}
}
}
}

Any idea ?

Thanks


(Shay Banon) #2

You mean you are using nested mapping for adress? If so, you need to use
nested filter (
http://www.elasticsearch.org/guide/reference/query-dsl/nested-filter.html)
or query (
http://www.elasticsearch.org/guide/reference/query-dsl/nested-query.html).

On Thu, Oct 6, 2011 at 10:10 AM, Alexandre Heimburger <
ahb@bluekiwi-software.com> wrote:

Hello,

Imagine that we have a nested field adress : adress.street, adress.zipCode
I cannot use a missing filter on adress :
{
"query": {
"constant_score": {
"filter": {
"missing": {
"field": "adress"
}
}
}
}
}

nor on sub-fields :
{
"query": {
"constant_score": {
"filter": {
"missing": {
"field": "adress.zipCode"
}
}
}
}
}

Any idea ?

Thanks


(alheim) #3

I'm sorry but I'm not sure to understand. Actually I did not use any
specific mapping. I just index the structure described in my post.

I've read and read and read again the documentation and I really don't get
how to make the missing filter working for that structure. Can you post any
example ?

Thanks a lot.


(Shay Banon) #4

Can you post a sample document that you index?

On Fri, Oct 7, 2011 at 9:18 AM, Alexandre Heimburger <
ahb@bluekiwi-software.com> wrote:

I'm sorry but I'm not sure to understand. Actually I did not use any
specific mapping. I just index the structure described in my post.

I've read and read and read again the documentation and I really don't get
how to make the missing filter working for that structure. Can you post any
example ?

Thanks a lot.


(alheim) #5

{
"firstName" : "Alex",
"lastName": "Heim",
"adress" : {
"zipCode": 92200,
"street": "street of philadelphia"
}
}

Querying missing field on adress does not work (i.e : return all the
entries)

Querying missing field on adress.zipCode works well.

I think I got the pattern. You can query on missing field if the field is
not nested (i.e is a string, numerical).

Do you confirm ?


(Shay Banon) #6

No, you can't do missing on a json object, just on concrete fields (that get
indexed).

On Mon, Oct 10, 2011 at 9:28 AM, Alexandre Heimburger <
ahb@bluekiwi-software.com> wrote:

{
"firstName" : "Alex",
"lastName": "Heim",
"adress" : {
"zipCode": 92200,
"street": "street of philadelphia"
}
}

Querying missing field on adress does not work (i.e : return all the
entries)

Querying missing field on adress.zipCode works well.

I think I got the pattern. You can query on missing field if the field is
not nested (i.e is a string, numerical).

Do you confirm ?


(system) #7