Facet values of nested documents?

I've used faceting for years in multiple search products and I've always
run into the following problem.

If I've a document like:

{
name: "foo",
status_id: 1,
status_name: "Super Awesome"
}

I can facet this document on status_id, then give my users a link to filter
by it, appending a status_id=1 to the URL, for example.

But I always have to make a choice. Facet by the computer-friendly id or
the human friendly name? I of course want to show the user the
status_name, but it's not really appropriate for use in the URL.

If I change my document to:

{
name: "foo",
status: {
id: 1,
name: "Super Awesome"
}
}

It seems I cannot simply say "facet on status" and get back the nested
object as a value.

What strategies do you guys use to solve this dilemma? Have I been
overlooking some painfully obvious mechanism to cleanly facet, provide
users with a friendly facet key and then specify a filter?*

  • I'm trying to avoid getting back a list of "ids" and retrieving them from
    the database.

Thanks!

--

Some thoughts.

  • If your number of status ids is really low, you can just render it on the web page as its name.
    (something with a switch like function).

  • You can facet on name and encode in BASE64 the name before adding it to the URL.

  • You can define your documents by concatenating id and name: "1|Super Awesome" and facet on that. Then, manage it on the interface side.

  • you can concatenate (just like above) but only when computing facet using script field: http://www.elasticsearch.org/guide/reference/api/search/facets/terms-facet.html

HTH

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

Le 18 août 2012 à 17:52, Cory G Watson jheephat@gmail.com a écrit :

I've used faceting for years in multiple search products and I've always run into the following problem.

If I've a document like:

{
name: "foo",
status_id: 1,
status_name: "Super Awesome"
}

I can facet this document on status_id, then give my users a link to filter by it, appending a status_id=1 to the URL, for example.

But I always have to make a choice. Facet by the computer-friendly id or the human friendly name? I of course want to show the user the status_name, but it's not really appropriate for use in the URL.

If I change my document to:

{
name: "foo",
status: {
id: 1,
name: "Super Awesome"
}
}

It seems I cannot simply say "facet on status" and get back the nested object as a value.

What strategies do you guys use to solve this dilemma? Have I been overlooking some painfully obvious mechanism to cleanly facet, provide users with a friendly facet key and then specify a filter?*

  • I'm trying to avoid getting back a list of "ids" and retrieving them from the database.

Thanks!

--