Lucene/Solr: facet an already faceted date field (pivot facet / tree facet / sub-facet / hierarchical facets)

StackOverflow https://stackoverflow.com/questions/4685855

  •  11-10-2019
  •  | 
  •  

Question

I am completely lost in a world of links and Solr terms. I currently have a date field which i facet, but i would like to face it 'further' if possible. An example: Field: date Field: language

So if i run this query:

http://host:port/solr/select/?q="Don Quijote"&sort=date+asc&facet=true&facet.date=date&facet.date.start=2010-09-01T00:00:00Z&facet.date.end=2010-09-04T23:59:59Z&facet.date.gap=%2B1DAY&facet.field=language&facet.mincount=1&start=0&rows=10

I get 2 different faceted fields:

One for 'date' like

2010-09-01 (10)

2010-09-02 (4)

2010-09-03 (60)

2010-09-04 (7)

etc

and one for 'language'

'English' (23)

'Spanish' (34)

'French' (32)

So my question is: How can i merge the 'language' field results into daily stats? I want at the end something like this:

2010-09-01 (10)

'English' (4)

'Spanish' (5)

'French'  (1)

2010-09-02 (4)

'English' (1)

'Spanish' (1)

'French'  (2)

2010-09-03 (60)

'English' (20)

'Spanish' (20)

'French'  (20)

2010-09-04 (7)

'English' (2)

'Spanish' (3)

'French'  (1)

Is this possible? I've lost myself in terms like pivot, tried the facet.tree=date,language approach and i'm not sure if what i'm looking for is the 'hierarchical facet'... Any pointers or guidance (but most of all, and example of how to do this with dates) will be appreciated. Thanks!

Some links read:

https://issues.apache.org/jira/browse/SOLR-792

https://issues.apache.org/jira/browse/SOLR-64

http://lucene.472066.n3.nabble.com/Hierarchical-Facets-td474308.html

http://lucene.472066.n3.nabble.com/Hierarchical-faceting-td1123548.html

http://www.craftyfella.com/2010/01/faceting-and-multifaceting-syntax-in.html

Was it helpful?

Solution

I'm not sure if date facets can be used in the facet.tree patch. If you haven't that many languages (or dates) you could simply index the fields in one field via

'date/lang'

and then facet on that one field only via facet.field=date_lang_merge_field

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top