On Mon, 2 Jun 2014, Andi Vajda wrote:


On Jun 2, 2014, at 2:04, Thomas Koch <k...@orbiteam.de> wrote:

Am 30.05.2014 um 23:08 schrieb Andi Vajda <va...@apache.org>:

Thanks Thomas !
Once you do that maybe it's time to make a 4.8.1 release too.
Let me know when you're ready with a fix.

TLDR;  fix is available: I've now revised the FacetExample.py to use the new 
API - it's tested to work with pylucene-4.8.0-1
The source can be found here:  
https://dl.dropboxusercontent.com/u/4384120/Python/FacetExample.py
Andi, can you please update the file in the repo? thanks.

details:  I should correct myself. The FacetExample was 'ported' to 4.x (with 
new fully qualified imports) already.
However in Java Lucene Release 4.7.0 [2014-02-26] some API Changes did break 
the code:
LUCENE-5339: The facet module was simplified/reworked to make the APIs more 
approachable to new users.

Note: when migrating to the new API, you must pass the Document that is returned
     from FacetConfig.build() to IndexWriter.addDocument().
     (Shai Erera, Gilad Barkai, Rob Muir, Mike McCandless)
see https://issues.apache.org/jira/browse/LUCENE-5339 for details!
(This was really a good and needed simplification of the Facet API!)

Some notes for those interested in facet search in Lucene:

- there are some Java samples available with Lucene Java, e.g.
 
http://svn.apache.org/repos/asf/lucene/dev/branches/lucene_solr_4_8/lucene/demo/src/java/org/apache/lucene/demo/facet/SimpleFacetsExample.java
 (which I took as a reference)

- back in 4.4 there was some good documentation (besides Javadocs) - the "Apache 
Lucene Faceted Search "User's Guide
http://lucene.apache.org/core/4_4_0/facet/org/apache/lucene/facet/doc-files/userguide.html

I can't find it for more recent versions though and according to Changelog it 
was removed with 4.5 because it's outdated:
LUCENE-4894: remove facet userguide as it was outdated. Partially absorbed into
            package's documentation and classes javadocs.
            (Shai Erera)
(still think it's partially useful introductory reading though...)

- developer hint:

whereas in Java you can write
doc.add(new FacetField("Publish Date", "2010", "10", "20"));
 here "Publish Date" is the 'dimension'
 and "2010", "10", "20" is the 'path'

in Python you need to declare the path as an array argument:
doc.add(FacetField("Publish Date", ["2010", "10", "20"]))


Java introduced 'varargs' feature to pass unspecified number of argument to a 
method in JDK 5.0.
Python can do similar by using the *args which can be passed a list of 
arguments - as positional arguments.
Seems however JCC does for some (probably good) reason not map Java varargs to 
python *args.

Thank you, Thomas, for the fix and explanations. There is no reason for JCC not to support Java's varargs feature other than it hasn't been implemented so far.

I've now done a first pass at adding support for Java varargs in JCC by reconstructing the last-args array the Java method actually expects during Python->Java argument parsing.
This is checked into svn trunk rev 1599407.

I tested this new feature with FacetExample.py. I removed all 'unnecessary' arrays and the sample still works !

This could use a bit of testing...

Andi..

Reply via email to