Hi Marc Schipperheyn, I finally got around working a bit more with facets and would like to get some feedback. I am working on HSEARCH-809 making use of the native faceting capabilities compared to our home-grown FieldCache collector approach we are having now.
With native Lucene faceting I basically have two options. Either dynamic faceting (just using SortedSetDocValuesFacetField and NumericDocValuesField; see also [1],[2]) or faceting via the taxonomy index. Even though the dynamic approach is a slower (~25%), it has the advantage that we don't have to maintain a second index. I am working at a change to implement faceting based on dynamic Lucene faceting as a first step. Most of your points above can be covered this way.
However, there is one use case which is not solvable via dynamic indexing, that is category trees (which you called drill down above). For that you need to use the taxonomy index. That said, I am wondering how you would configure the required category tree. For example using pure Lucene API you would do:
Document doc = new Document();
doc.add(new FacetField("Publish Date", "2010", "10", "15"));
indexWriter.addDocument(config.build(taxoWriter, doc));
In this case the publish date is broken down into year, month and day. How do you configure that if your entity has:
@Field
@Facet Date publishDate;
Somehow you would need a contract which tells you how to build the tree given a property or more likely given a whole instance (in the case the multiple entity properties contribute to the path). You need something like:
@Indexed
@FacetCategoryBuilder(facet="publishDate", impl=Foo.class)
class Book {
@Field
@Facet
Date publishDate;
}
In the example above you probably would like to place @FacetCategoryBuilder directly on publishDate and defaulting the name, but in a more general case you would need to be able to place it on type level as well.
Anyways, this are just some initial thoughts of mine around this. I was wondering whether you have thought about this as well? (mind you with my current work we won't be able to do this anyways, but I want to see if and how it would be possible, if we had the taxonomy index.)
[1] http://blog.mikemccandless.com/2013/05/dynamic-faceting-with-lucene.html [2] http://www.norconex.com/facets-with-lucene/
|