Nested type, facet, and filters

Hello,

I've got documents with nested objects.
(i'm using ElasticSearch 0.90.2)

I would like to have term facets on these objects (I know how to do it).
Now, I would like to filter this facet on a field that belongs to the root
object, not to the nested object.

I've created a gist with my test (mapping, data & request) :

Without the filter, the term facet contains all terms (FOO, BAR, BAZ) :

{
"query": {
"match_all": {}
},
"facets": {
"facet_situations": {
"global": true,
"nested": "situations",
"terms": {
"field": "situations.type"
}
}
}
}

With the term filter, the facet is empty

{
"query": {
"match_all": {}
},
"facets": {
"facet_situations": {
"global": true,
"nested": "situations",
"terms": {
"field": "situations.type"
},
"facet_filter": {
"term": {
"record.reference": "RECORD-2"
}
}
}
}
}

Is it possible to filter the facet with root object fields ?

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Does a FilteredQuery could work for you?

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 12 août 2013 à 21:52, Damien Ferey damien.ferey@gmail.com a écrit :

Hello,

I've got documents with nested objects.
(i'm using ElasticSearch 0.90.2)

I would like to have term facets on these objects (I know how to do it).
Now, I would like to filter this facet on a field that belongs to the root object, not to the nested object.

I've created a gist with my test (mapping, data & request) :

Without the filter, the term facet contains all terms (FOO, BAR, BAZ) :
{
"query": {
"match_all": {}
},
"facets": {
"facet_situations": {
"global": true,
"nested": "situations",
"terms": {
"field": "situations.type"
}
}
}
}

With the term filter, the facet is empty
{
"query": {
"match_all": {}
},
"facets": {
"facet_situations": {
"global": true,
"nested": "situations",
"terms": {
"field": "situations.type"
},
"facet_filter": {
"term": {
"record.reference": "RECORD-2"
}
}
}
}
}

Is it possible to filter the facet with root object fields ?

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

if it's possible to put the FilteredQuery in the facet_filter, yes, it
could work.
(do you have an example ?)

If you meant use a FilteredQuery instead of matchall, it could not work
for me : in my app, I need to have facets that have different filters from
main query.

Damien

Le lundi 12 août 2013 22:01:05 UTC+2, David Pilato a écrit :

Does a FilteredQuery could work for you?

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 12 août 2013 à 21:52, Damien Ferey <damien...@gmail.com <javascript:>>
a écrit :

Hello,

I've got documents with nested objects.
(i'm using ElasticSearch 0.90.2)

I would like to have term facets on these objects (I know how to do it).
Now, I would like to filter this facet on a field that belongs to the root
object, not to the nested object.

I've created a gist with my test (mapping, data & request) :
https://gist.github.com/MarneusCalgarXP/473d6d72c5ae7dc04a11

Without the filter, the term facet contains all terms (FOO, BAR, BAZ) :

{
"query": {
"match_all": {}
},
"facets": {
"facet_situations": {
"global": true,
"nested": "situations",
"terms": {
"field": "situations.type"
}
}
}
}

With the term filter, the facet is empty

{
"query": {
"match_all": {}
},
"facets": {
"facet_situations": {
"global": true,
"nested": "situations",
"terms": {
"field": "situations.type"
},
"facet_filter": {
"term": {
"record.reference": "RECORD-2"
}
}
}
}
}

Is it possible to filter the facet with root object fields ?

--
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 elasticsearc...@googlegroups.com <javascript:>.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Sadly I meant the second option.
I don't know (yet) if there is another option.

If not, you can probably use multisearch API with Filtered Queries (in place of matchAll).

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 12 août 2013 à 22:05, Damien Ferey damien.ferey@gmail.com a écrit :

if it's possible to put the FilteredQuery in the facet_filter, yes, it could work.
(do you have an example ?)

If you meant use a FilteredQuery instead of matchall, it could not work for me : in my app, I need to have facets that have different filters from main query.

Damien

Le lundi 12 août 2013 22:01:05 UTC+2, David Pilato a écrit :

Does a FilteredQuery could work for you?

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 12 août 2013 à 21:52, Damien Ferey damien...@gmail.com a écrit :

Hello,

I've got documents with nested objects.
(i'm using ElasticSearch 0.90.2)

I would like to have term facets on these objects (I know how to do it).
Now, I would like to filter this facet on a field that belongs to the root object, not to the nested object.

I've created a gist with my test (mapping, data & request) :
https://gist.github.com/MarneusCalgarXP/473d6d72c5ae7dc04a11

Without the filter, the term facet contains all terms (FOO, BAR, BAZ) :
{
"query": {
"match_all": {}
},
"facets": {
"facet_situations": {
"global": true,
"nested": "situations",
"terms": {
"field": "situations.type"
}
}
}
}

With the term filter, the facet is empty
{
"query": {
"match_all": {}
},
"facets": {
"facet_situations": {
"global": true,
"nested": "situations",
"terms": {
"field": "situations.type"
},
"facet_filter": {
"term": {
"record.reference": "RECORD-2"
}
}
}
}
}

Is it possible to filter the facet with root object fields ?

--
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 elasticsearc...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

And if I swith to a parent/child model, is it possible to request facet on
children ?

(if not, I will give a try to multi search)

Le lundi 12 août 2013 23:24:13 UTC+2, David Pilato a écrit :

Sadly I meant the second option.
I don't know (yet) if there is another option.

If not, you can probably use multisearch API with Filtered Queries (in
place of matchAll).

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 12 août 2013 à 22:05, Damien Ferey <damien...@gmail.com <javascript:>>
a écrit :

if it's possible to put the FilteredQuery in the facet_filter, yes, it
could work.
(do you have an example ?)

If you meant use a FilteredQuery instead of matchall, it could not work
for me : in my app, I need to have facets that have different filters from
main query.

Damien

Le lundi 12 août 2013 22:01:05 UTC+2, David Pilato a écrit :

Does a FilteredQuery could work for you?

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 12 août 2013 à 21:52, Damien Ferey damien...@gmail.com a écrit :

Hello,

I've got documents with nested objects.
(i'm using ElasticSearch 0.90.2)

I would like to have term facets on these objects (I know how to do it).
Now, I would like to filter this facet on a field that belongs to the
root object, not to the nested object.

I've created a gist with my test (mapping, data & request) :
https://gist.github.com/MarneusCalgarXP/473d6d72c5ae7dc04a11

Without the filter, the term facet contains all terms (FOO, BAR, BAZ) :

{
"query": {
"match_all": {}
},
"facets": {
"facet_situations": {
"global": true,
"nested": "situations",
"terms": {
"field": "situations.type"
}
}
}
}

With the term filter, the facet is empty

{
"query": {
"match_all": {}
},
"facets": {
"facet_situations": {
"global": true,
"nested": "situations",
"terms": {
"field": "situations.type"
},
"facet_filter": {
"term": {
"record.reference": "RECORD-2"
}
}
}
}
}

Is it possible to filter the facet with root object fields ?

--
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 elasticsearc...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
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 elasticsearc...@googlegroups.com <javascript:>.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

I've tried with Multi Search, it works !

Thank you !

Le mardi 13 août 2013 09:19:15 UTC+2, Damien Ferey a écrit :

And if I swith to a parent/child model, is it possible to request facet on
children ?

(if not, I will give a try to multi search)

Le lundi 12 août 2013 23:24:13 UTC+2, David Pilato a écrit :

Sadly I meant the second option.
I don't know (yet) if there is another option.

If not, you can probably use multisearch API with Filtered Queries (in
place of matchAll).

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 12 août 2013 à 22:05, Damien Ferey damien...@gmail.com a écrit :

if it's possible to put the FilteredQuery in the facet_filter, yes, it
could work.
(do you have an example ?)

If you meant use a FilteredQuery instead of matchall, it could not work
for me : in my app, I need to have facets that have different filters from
main query.

Damien

Le lundi 12 août 2013 22:01:05 UTC+2, David Pilato a écrit :

Does a FilteredQuery could work for you?

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 12 août 2013 à 21:52, Damien Ferey damien...@gmail.com a écrit :

Hello,

I've got documents with nested objects.
(i'm using ElasticSearch 0.90.2)

I would like to have term facets on these objects (I know how to do it).
Now, I would like to filter this facet on a field that belongs to the
root object, not to the nested object.

I've created a gist with my test (mapping, data & request) :
https://gist.github.com/MarneusCalgarXP/473d6d72c5ae7dc04a11

Without the filter, the term facet contains all terms (FOO, BAR, BAZ) :

{
"query": {
"match_all": {}
},
"facets": {
"facet_situations": {
"global": true,
"nested": "situations",
"terms": {
"field": "situations.type"
}
}
}
}

With the term filter, the facet is empty

{
"query": {
"match_all": {}
},
"facets": {
"facet_situations": {
"global": true,
"nested": "situations",
"terms": {
"field": "situations.type"
},
"facet_filter": {
"term": {
"record.reference": "RECORD-2"
}
}
}
}
}

Is it possible to filter the facet with root object fields ?

--
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 elasticsearc...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
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 elasticsearc...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.