Adaptive faceted searching

Hi,

Filters can narrow down the number of documents returned in the search, but
this won't affect the document counts per facet due to the narrowing
applied by the filter.

I want to be able to select any number of facets in my search solution (via
facet filters) and then have the list of facets update with the number of
results per facet after the narrowing has been applied. This means that,
of the documents remain after the facet filter has been applied, the list
of facets will return only the counts that apply to the remaining
documents.

How can I achieve this adaptive faceted search in an elasticsearch query?

//
Example:
I have 10 documents in my search index, 5 of which have the tag "rails",
and all 10 of which have the tag "ruby"

if I select the "rails" tag, then I should end up with the following
available facets (and counts):

  • ruby (5)
  • rails (5)

If I select the "ruby" tag, then I should end up with the following
available facets (and counts):

  • ruby (10)
  • rails (5)

If I select both the "ruby" and the "rails" tags (this means results that
have both the ruby tag and the rails tag), then I should end up with the
following facets (and counts):

  • ruby (5)
  • rails (5)

--
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 have to apply the same filters to each facet using facet filter:
{
"facets" : {
"" : {
"" : {
...
},
"facet_filter" : {
"term" : { "user" : "kimchy"}
}
}
}
}
HTH
David

Le 5 févr. 2013 à 08:40, JL jonathan.liang@gmail.com a écrit :

Hi,

Filters can narrow down the number of documents returned in the search, but this won't affect the document counts per facet due to the narrowing applied by the filter.

I want to be able to select any number of facets in my search solution (via facet filters) and then have the list of facets update with the number of results per facet after the narrowing has been applied. This means that, of the documents remain after the facet filter has been applied, the list of facets will return only the counts that apply to the remaining documents.

How can I achieve this adaptive faceted search in an elasticsearch query?

//
Example:
I have 10 documents in my search index, 5 of which have the tag "rails", and all 10 of which have the tag "ruby"

if I select the "rails" tag, then I should end up with the following available facets (and counts):

  • ruby (5)
  • rails (5)

If I select the "ruby" tag, then I should end up with the following available facets (and counts):

  • ruby (10)
  • rails (5)

If I select both the "ruby" and the "rails" tags (this means results that have both the ruby tag and the rails tag), then I should end up with the following facets (and counts):

  • ruby (5)
  • rails (5)

--
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.

Does it make any difference if I do it via filtered search? This way I can
combine it with search and also limit hits using my facet-derived filter
(do not know if facet_filter affects number of hits or not - have not tried
it yet). I've built entirely generic facet navigation UI using this
approach seems to work well...

"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"bool": {
"must": [
{
"terms": {
"award.type.id": [4000, 1000]
}
},
{
"terms": {
"fy": [2012, 2011, 2010, 2009, 2008, 2007, 2006, 2005]
}
}
]
}
}
}
}

--
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.