Facet Filter by Element and Element Sibling


(Owen Coutts) #1

Hello All,

I'm looking to do a facet filter on documents that look like
thishttp://pastebin.com/Dgy7YwKWone.

I have an array named "results" and within that array I have elements with
field "name" and field "failed". I'd like to do a facet search over the
"name" field across all elements of the "results" array in in all documents.
Furthermore, I'd like to be able to filter out all elements where "failed"
(the sibling of "name") is 0. How would I do this?

I've tried looking at the Term
Scriptshttp://www.elasticsearch.org/guide/reference/api/search/facets/terms-facet.htmldocumentation
but I don't think I am able to access the sibling from the
script.

Does _scope allow this to happen? Could I somehow scope the facets down to
an individual element in "results"?

Thanks for your help,
Owen Coutts

--
Owen Coutts
owen@owencoutts.com


(Shay Banon) #2

You will loose the notion of order between two different fields in this case. You will filter by docs that have failed set to 0, but then that doc becomes "qualified" to do terms stats on it. What you can do is separate each element in the array to a different doc.

On Wednesday, June 1, 2011 at 2:07 AM, Owen Coutts wrote:

Hello All,

I'm looking to do a facet filter on documents that look like this (http://pastebin.com/Dgy7YwKW) one.

I have an array named "results" and within that array I have elements with field "name" and field "failed". I'd like to do a facet search over the "name" field across all elements of the "results" array in in all documents. Furthermore, I'd like to be able to filter out all elements where "failed" (the sibling of "name") is 0. How would I do this?

I've tried looking at the Term Scripts (http://www.elasticsearch.org/guide/reference/api/search/facets/terms-facet.html) documentation but I don't think I am able to access the sibling from the script.

Does _scope allow this to happen? Could I somehow scope the facets down to an individual element in "results"?

Thanks for your help,
Owen Coutts

--
Owen Coutts
owen@owencoutts.com (mailto:owen@owencoutts.com)


(Owen Coutts) #3

How would I do that while keeping the meta data (at the root of the current
doc) in the index for each result? Should I create separate documents where
the meta data is repeated?

On Tue, May 31, 2011 at 4:54 PM, Shay Banon shay.banon@elasticsearch.comwrote:

You will loose the notion of order between two different fields in this
case. You will filter by docs that have failed set to 0, but then that doc
becomes "qualified" to do terms stats on it. What you can do is separate
each element in the array to a different doc.

On Wednesday, June 1, 2011 at 2:07 AM, Owen Coutts wrote:

Hello All,

I'm looking to do a facet filter on documents that look like thishttp://pastebin.com/Dgy7YwKWone.

I have an array named "results" and within that array I have elements with
field "name" and field "failed". I'd like to do a facet search over the
"name" field across all elements of the "results" array in in all documents.
Furthermore, I'd like to be able to filter out all elements where "failed"
(the sibling of "name") is 0. How would I do this?

I've tried looking at the Term Scriptshttp://www.elasticsearch.org/guide/reference/api/search/facets/terms-facet.htmldocumentation but I don't think I am able to access the sibling from the
script.

Does _scope allow this to happen? Could I somehow scope the facets down to
an individual element in "results"?

Thanks for your help,
Owen Coutts

--
Owen Coutts
owen@owencoutts.com

--
Owen Coutts
University of Waterloo

--
Email: owen@owencoutts.com
Phone: 519.729.3859
Book a Meeting With Me: tungle.me/ocoutts


(Shay Banon) #4

You will need to repeat the metadata in each document, or, use the parent child feature (at the cost of slower searches with has_child filter or top_children query).

On Wednesday, June 1, 2011 at 4:01 AM, Owen Coutts wrote:

How would I do that while keeping the meta data (at the root of the current doc) in the index for each result? Should I create separate documents where the meta data is repeated?

On Tue, May 31, 2011 at 4:54 PM, Shay Banon <shay.banon@elasticsearch.com (mailto:shay.banon@elasticsearch.com)> wrote:

You will loose the notion of order between two different fields in this case. You will filter by docs that have failed set to 0, but then that doc becomes "qualified" to do terms stats on it. What you can do is separate each element in the array to a different doc.

On Wednesday, June 1, 2011 at 2:07 AM, Owen Coutts wrote:

Hello All,

I'm looking to do a facet filter on documents that look like this (http://pastebin.com/Dgy7YwKW) one.

I have an array named "results" and within that array I have elements with field "name" and field "failed". I'd like to do a facet search over the "name" field across all elements of the "results" array in in all documents. Furthermore, I'd like to be able to filter out all elements where "failed" (the sibling of "name") is 0. How would I do this?

I've tried looking at the Term Scripts (http://www.elasticsearch.org/guide/reference/api/search/facets/terms-facet.html) documentation but I don't think I am able to access the sibling from the script.

Does _scope allow this to happen? Could I somehow scope the facets down to an individual element in "results"?

Thanks for your help,
Owen Coutts

--
Owen Coutts
owen@owencoutts.com (mailto:owen@owencoutts.com)

--
Owen Coutts
University of Waterloo

--
Email: owen@owencoutts.com (mailto:owen@owencoutts.com)
Phone: 519.729.3859 (tel:519.729.3859)
Book a Meeting With Me: tungle.me/ocoutts (http://tungle.me/ocoutts)


(system) #5