Filtering nested documents for faceting

Hi all-

I'm trying to build a faceted navigation UX on a corpus with documents
containing many (thousands of) properties. Users will be applying multiple
filters (filter such as: documents must contain an assignment for property
'X' that matches 'Y') to reduce their current document set to manageable
size. To power this UI, I'd like to provide a 'typeahead' experience--users
can begin typing out the names of properties (or assignments), and this
text will be matched using match_phrase_prefix. That is solved for
filtering documents (without typeahead) very easily (I already have it
working).

What I'd like to now do is filter facets based on the search term. That
is, I'd like to return property names (and values) as the user types into a
search box, with counts of documents that have assignments for that
property name and value. As an example, a user has selected 'Category >
Camcorders' and the user is now searching the text 'Son', they will be
presented with an option 'Manufacturer > Sony (53)', where 53 is the count
of documents which have a property value assignment of 'Sony' for the
'Manufacturer' field, as it pertains to the already applied filters,
i.e., there are 53 Sony camcorders in the corpus.

My (slimmed down) mapping is here:

As in the gist, I have added assignments as nested docs, and I'm using
nested faceting to provide an unfiltered view of the property assignments
based on the user's current set of filters (i.e., I can show a user what
properties and values are assigned to documents that are tagged as Sony
Camcorders, as well as the number of documents that those properties and
values are tagged on). But I can't figure out how to filter the facet
results based on a user's text.

Any suggestions would be appreciated.

Thanks,

-Dan

--

Hi Dan,

Can you share your search request or the relevant parts of it?

At all times if you want the filter on nested fields you need to use
the nested filter:

Inside the nested filter you can embed whatever filter you need to
execute on the nested docs.

Martijn

On 2 December 2012 09:02, Dan Spangenberger dspangenberger@salsify.com wrote:

Hi all-

I'm trying to build a faceted navigation UX on a corpus with documents
containing many (thousands of) properties. Users will be applying multiple
filters (filter such as: documents must contain an assignment for property
'X' that matches 'Y') to reduce their current document set to manageable
size. To power this UI, I'd like to provide a 'typeahead' experience--users
can begin typing out the names of properties (or assignments), and this text
will be matched using match_phrase_prefix. That is solved for filtering
documents (without typeahead) very easily (I already have it working).

What I'd like to now do is filter facets based on the search term. That is,
I'd like to return property names (and values) as the user types into a
search box, with counts of documents that have assignments for that property
name and value. As an example, a user has selected 'Category > Camcorders'
and the user is now searching the text 'Son', they will be presented with an
option 'Manufacturer > Sony (53)', where 53 is the count of documents which
have a property value assignment of 'Sony' for the 'Manufacturer' field, as
it pertains to the already applied filters, i.e., there are 53 Sony
camcorders in the corpus.

My (slimmed down) mapping is here:

ES mapping for docs · GitHub

As in the gist, I have added assignments as nested docs, and I'm using
nested faceting to provide an unfiltered view of the property assignments
based on the user's current set of filters (i.e., I can show a user what
properties and values are assigned to documents that are tagged as Sony
Camcorders, as well as the number of documents that those properties and
values are tagged on). But I can't figure out how to filter the facet
results based on a user's text.

Any suggestions would be appreciated.

Thanks,

-Dan

--

--
Met vriendelijke groet,

Martijn van Groningen

--

I've updated the gist: ES mapping for docs · GitHub

In the (fairly simplified) query I've provided, I can filter the document
set to facet on, using facet_filter, but the facet values coming back are
not filtered--they still include entries for other manufacturers. That's
what I'd like to filter. I suspect that this will likely involve another
index, or a faceting plugin, but I'm hopeful that it may not (or someone
can give me some guidance on where to start building that)

-Dan

On Monday, December 3, 2012 7:49:17 AM UTC-5, Martijn v Groningen wrote:

Hi Dan,

Can you share your search request or the relevant parts of it?

At all times if you want the filter on nested fields you need to use
the nested filter:
Elasticsearch Platform — Find real-time answers at scale | Elastic

Inside the nested filter you can embed whatever filter you need to
execute on the nested docs.

Martijn

On 2 December 2012 09:02, Dan Spangenberger <dspange...@salsify.com<javascript:>>
wrote:

Hi all-

I'm trying to build a faceted navigation UX on a corpus with documents
containing many (thousands of) properties. Users will be applying
multiple
filters (filter such as: documents must contain an assignment for
property
'X' that matches 'Y') to reduce their current document set to manageable
size. To power this UI, I'd like to provide a 'typeahead'
experience--users
can begin typing out the names of properties (or assignments), and this
text
will be matched using match_phrase_prefix. That is solved for filtering
documents (without typeahead) very easily (I already have it working).

What I'd like to now do is filter facets based on the search term. That
is,
I'd like to return property names (and values) as the user types into a
search box, with counts of documents that have assignments for that
property
name and value. As an example, a user has selected 'Category >
Camcorders'
and the user is now searching the text 'Son', they will be presented
with an
option 'Manufacturer > Sony (53)', where 53 is the count of documents
which
have a property value assignment of 'Sony' for the 'Manufacturer' field,
as
it pertains to the already applied filters, i.e., there are 53 Sony
camcorders in the corpus.

My (slimmed down) mapping is here:

ES mapping for docs · GitHub

As in the gist, I have added assignments as nested docs, and I'm using
nested faceting to provide an unfiltered view of the property
assignments
based on the user's current set of filters (i.e., I can show a user what
properties and values are assigned to documents that are tagged as Sony
Camcorders, as well as the number of documents that those properties and
values are tagged on). But I can't figure out how to filter the facet
results based on a user's text.

Any suggestions would be appreciated.

Thanks,

-Dan

--

--
Met vriendelijke groet,

Martijn van Groningen

--

Hi Dan,

Inside the facet_filter search request parts you also need to use
the nested filters, just like you already do in the query request
part.

Martijn

On 4 December 2012 02:26, Dan Spangenberger dspangenberger@salsify.com wrote:

I've updated the gist: ES mapping for docs · GitHub

In the (fairly simplified) query I've provided, I can filter the document
set to facet on, using facet_filter, but the facet values coming back are
not filtered--they still include entries for other manufacturers. That's
what I'd like to filter. I suspect that this will likely involve another
index, or a faceting plugin, but I'm hopeful that it may not (or someone can
give me some guidance on where to start building that)

-Dan

On Monday, December 3, 2012 7:49:17 AM UTC-5, Martijn v Groningen wrote:

Hi Dan,

Can you share your search request or the relevant parts of it?

At all times if you want the filter on nested fields you need to use
the nested filter:
Elasticsearch Platform — Find real-time answers at scale | Elastic

Inside the nested filter you can embed whatever filter you need to
execute on the nested docs.

Martijn

On 2 December 2012 09:02, Dan Spangenberger dspange...@salsify.com
wrote:

Hi all-

I'm trying to build a faceted navigation UX on a corpus with documents
containing many (thousands of) properties. Users will be applying
multiple
filters (filter such as: documents must contain an assignment for
property
'X' that matches 'Y') to reduce their current document set to manageable
size. To power this UI, I'd like to provide a 'typeahead'
experience--users
can begin typing out the names of properties (or assignments), and this
text
will be matched using match_phrase_prefix. That is solved for filtering
documents (without typeahead) very easily (I already have it working).

What I'd like to now do is filter facets based on the search term. That
is,
I'd like to return property names (and values) as the user types into a
search box, with counts of documents that have assignments for that
property
name and value. As an example, a user has selected 'Category >
Camcorders'
and the user is now searching the text 'Son', they will be presented
with an
option 'Manufacturer > Sony (53)', where 53 is the count of documents
which
have a property value assignment of 'Sony' for the 'Manufacturer' field,
as
it pertains to the already applied filters, i.e., there are 53 Sony
camcorders in the corpus.

My (slimmed down) mapping is here:

ES mapping for docs · GitHub

As in the gist, I have added assignments as nested docs, and I'm using
nested faceting to provide an unfiltered view of the property
assignments
based on the user's current set of filters (i.e., I can show a user what
properties and values are assigned to documents that are tagged as Sony
Camcorders, as well as the number of documents that those properties and
values are tagged on). But I can't figure out how to filter the facet
results based on a user's text.

Any suggestions would be appreciated.

Thanks,

-Dan

--

--
Met vriendelijke groet,

Martijn van Groningen

--

--
Met vriendelijke groet,

Martijn van Groningen

--