Facets : limit the terms values to a list?

Hi,

I'm actually working on a faceted search, and I can't find a good
solution to a problem (in the docs nor with my best friend Google ;)).

One of the facets I have to manage has to be hierarchical (it's a
category filter, one record can have multiple categories of multiple
levels). Example :

  1. First level on search :
    [ ] Computers (10)
    [ ] Sea (5)
  2. User checks "Computers". We have to give him all records associated
    to category "computers" (or to any subcategory), and to propose the
    sub-categories facetized :
    [ x ] Computers (10)
    [ ] Internet (6)
    [ ] Hardware (2)

My problem is to get only facet counts for categories under
"Computers", as a record can be associated to "Internet" and to a
subcategory of "Sea".

The only solution I can find for the moment, is to use the "regex"
param with a list of ids corresponding to subcategories of
"Computer" ( regex : "1|2|3"), but it's not really elegant.

Does somebody have a better idea/solution to filter the terms ?

Thanks !
Sebastien

Hi Sebastien

One of the facets I have to manage has to be hierarchical (it's a
category filter, one record can have multiple categories of multiple
levels). Example :

  1. First level on search :
    [ ] Computers (10)
    [ ] Sea (5)
  2. User checks "Computers". We have to give him all records associated
    to category "computers" (or to any subcategory), and to propose the
    sub-categories facetized :
    [ x ] Computers (10)
    [ ] Internet (6)
    [ ] Hardware (2)

My problem is to get only facet counts for categories under
"Computers", as a record can be associated to "Internet" and to a
subcategory of "Sea".

The only solution I can find for the moment, is to use the "regex"
param with a list of ids corresponding to subcategories of
"Computer" ( regex : "1|2|3"), but it's not really elegant.

I'd suggest storing your tags as:
computers
computers_internet
computers_hardware
sea
sea_internet
sea_surf

That way, your regex can just look like "^computers_"

You could additionally store 'internet','hardware',and 'surf' tags to
allow searching directly on those, if you need to

clint

I've managed to solve this in Solr and the procedure is described
here:

and yes, sadly you'll have to filter away via regex (or facet.prefix
in Solr)

Peter.

On 21 Dez., 11:19, Sébastien Charrier scharr...@gmail.com wrote:

Hi,

I'm actually working on a faceted search, and I can't find a good
solution to a problem (in the docs nor with my best friend Google ;)).

One of the facets I have to manage has to be hierarchical (it's a
category filter, one record can have multiple categories of multiple
levels). Example :

  1. First level on search :
    [ ] Computers (10)
    [ ] Sea (5)
  2. User checks "Computers". We have to give him all records associated
    to category "computers" (or to any subcategory), and to propose the
    sub-categories facetized :
    [ x ] Computers (10)
    [ ] Internet (6)
    [ ] Hardware (2)

My problem is to get only facet counts for categories under
"Computers", as a record can be associated to "Internet" and to a
subcategory of "Sea".

The only solution I can find for the moment, is to use the "regex"
param with a list of ids corresponding to subcategories of
"Computer" ( regex : "1|2|3"), but it's not really elegant.

Does somebody have a better idea/solution to filter the terms ?

Thanks !
Sebastien

Thanks for your 2 replies !

I have a field wich contains all the ids path ("1 2 3"), wich i'll use
for filter my terms. So ... let's go for regex !

Sebastien

On Dec 21, 1:40 pm, Karussell tableyourt...@googlemail.com wrote:

I've managed to solve this in Solr and the procedure is described
here:

Use cases of faceted search for Apache Solr | Karussell...

and yes, sadly you'll have to filter away via regex (or facet.prefix
in Solr)

Peter.

On 21 Dez., 11:19, Sébastien Charrier scharr...@gmail.com wrote:

Hi,

I'm actually working on a faceted search, and I can't find a good
solution to a problem (in the docs nor with my best friend Google ;)).

One of the facets I have to manage has to be hierarchical (it's a
category filter, one record can have multiple categories of multiple
levels). Example :

  1. First level on search :
    [ ] Computers (10)
    [ ] Sea (5)
  2. User checks "Computers". We have to give him all records associated
    to category "computers" (or to any subcategory), and to propose the
    sub-categories facetized :
    [ x ] Computers (10)
    [ ] Internet (6)
    [ ] Hardware (2)

My problem is to get only facet counts for categories under
"Computers", as a record can be associated to "Internet" and to a
subcategory of "Sea".

The only solution I can find for the moment, is to use the "regex"
param with a list of ids corresponding to subcategories of
"Computer" ( regex : "1|2|3"), but it's not really elegant.

Does somebody have a better idea/solution to filter the terms ?

Thanks !
Sebastien

Hi,

I store two values in my ES index:
'category_id': {'type': 'integer'},
'category_ids': {'type': 'integer'},

where the second one is only for facets. It's not a path of ids
(string), but list of integers. I'm not sure it's the best solution, but
i don't need to use regex. my query looks like:

"query": {"match_all": {}}}}, "facets": {"category_ids": {"terms":
{"field": "category_ids", "size": 20}}}, "from": 0, "size": 10}

On 21.12.2011 14:19, Sébastien Charrier wrote:

Thanks for your 2 replies !

I have a field wich contains all the ids path ("1 2 3"), wich i'll use
for filter my terms. So ... let's go for regex !

Sebastien