Hi Andi, You're right - and API docs are wrong. Actually both must have change after 4.1 release: I checked the source of java-lucene v4.1 (lucene-4.1.0-src.tgz / 21-Jan-2013) and it matches the online javadocs. So I guess you're preparing for PyLucene v4.2?
Note: I think that LUCENE_SVN=http://svn.apache.org/repos/asf/lucene/dev/branches/branch_4x is the "trunk" where 4.x development happens (i.e. "unstable") whereas http://svn.apache.org/repos/asf/lucene/dev/branches/lucene_solr_4_1/ is the "stable" Lucene4.1/Solr4.1 branch (matching the 4.1 release and API docs). So if that's right (please correct me if I'm wrong) - why did you choose the branch_4x? Anyway, I fixed the FacetsExample.py for branch_4x now ,-) Some notes on API changes for those interested: -the 'new' FacetsCollector has a factory pattern now: public static FacetsCollector create(FacetSearchParams fsp, IndexReader indexReader, TaxonomyReader taxoReader) - the order of constructor arguments for FacetSearchParams has changed! - FacetResultNode has changed: it used to be an interface but is now a concrete class (and the method getSubResults of FacetResultNode disappeared) - DrillDown.query() became DrillDownQuery() - with a new API. Well, at least API docs state it: "WARNING: This API is experimental and might change in incompatible ways in the next release." So one should be warned... Here's the new version: https://dl.dropbox.com/u/4384120/FacetExample.py Or as patch to svn: https://dl.dropbox.com/u/4384120/FacetExample_patch_20130213.txt Thanks again for your help. regards, Thomas -- Am 12.02.2013 um 22:36 schrieb Andi Vajda <va...@apache.org>: > > Hi Thomas, > > On Tue, 12 Feb 2013, Thomas Koch wrote: > >> Thanks to your hints I was now able to build PyLucene4.1 and got further >> with the FacetExample.py - The imports should be OK now and most of the >> required changes are done I guess. However I now reached another problem: I >> need to instantiate the class 'FacetsCollector' but get an error when doing >> so: >> >> File "samples/FacetExample.py", line 222, in searchWithRequestAndQuery >> facetsCollector = FacetsCollector(facetSearchParams, indexReader, >> taxoReader) >> NotImplementedError: ('instantiating java class', <type 'FacetsCollector'>) >> >> The java example has this line: >> FacetsCollector facetsCollector = new FacetsCollector(facetSearchParams, >> indexReader, taxoReader); >> and javadocs state it has a public constructor: >> http://lucene.apache.org/core/4_1_0/facet/org/apache/lucene/facet/search/FacetsCollector.html#FacetsCollector(org.apache.lucene.facet.search.params.FacetSearchParams,%20org.apache.lucene.index.IndexReader,%20org.apache.lucene.facet.taxonomy.TaxonomyReader) >> >> So what could be the reason for this behavior? > > The FacetCollector class is declared abstract. Thus you can't instantiate it, > constructor or not. I think the intent is to instantiate one of its concrete > inner subclasses. > See > lucene-java-4.1/lucene/facet/src/java/org/apache/lucene/facet/search/FacetsCollector.java > >> I have another problem with the constructor of FacetSearchParams: it is >> expecting arguments: >> (List<FacetRequest> facetRequests, FacetIndexingParams indexingParams) >> but neither >> FacetSearchParams(Arrays.asList([facetRequest,]), indexingParams) >> nor >> FacetSearchParams([facetRequest,], indexingParams) >> does it here. I get >> >> lucene.InvalidArgsError: (<type 'FacetSearchParams'>, '__init__', (<List: >> [root/a nRes=10 nLbl=10]>, <FacetIndexingParams: >> org.apache.lucene.facet.params.FacetIndexingParams@f97ad3c0>)) > > There are four constructors on FacetSearchParams, none of which seems to > match your call: > public FacetSearchParams(FacetRequest... facetRequests) > public FacetSearchParams(List<FacetRequest> facetRequests) > public FacetSearchParams(FacetIndexingParams indexingParams, FacetRequest... > facetRequests) > public FacetSearchParams(FacetIndexingParams indexingParams, > List<FacetRequest> facetRequests) > > See > lucene-java-4.1/lucene/facet/src/java/org/apache/lucene/facet/params/FacetSearchParams.java > > You seem to be passing FacetIndexingParams last. > > Andi.. > > >> >> I thought that JavaList could help, but I cannot import it: >>>>> from lucene.collections import JavaList >> Traceback (most recent call last): >> File "<stdin>", line 1, in <module> >> File >> "/Users/koch/.virtualenvs/pylucene/lib/python2.7/site-packages/lucene-4.1-py2.7-macosx-10.8-x86_64.egg/lucene/collections.py", >> line 17, in <module> >> from org.apache.pylucene.util import \ >> ImportError: No module named pylucene.util >>>>> >> >> That's probably because I had to disable in Makefile >> ## JARS+=$(HIGHLIGHTER_JAR) # needs memory contrib >> ## JARS+=$(EXTENSIONS_JAR) # needs highlighter contrib >> >> Do you think that's a type cast issue and that JavaList would help here? >> I need to define a 'typed' list , e.g. List<FacetRequest> >> >> FacetSearchParams API docs: >> http://lucene.apache.org/core/4_1_0/facet/org/apache/lucene/facet/search/params/FacetSearchParams.html >> >> Current version of FacetExample.py >> https://dl.dropbox.com/u/4384120/FacetExample.py >> >> Any hints? >> >> regards, >> Thomas >> -- >> Am 12.02.2013 um 09:19 schrieb Andi Vajda <va...@apache.org>: >> >>> >>> On Tue, 12 Feb 2013, Andi Vajda wrote: >>> >>>> Indeed. I reproduced that error here. >>>> A new method was added to the FieldCache.Parser interface. >>>> I added it to the classes missing it (rev 1445048). >>>> >>>> I then found that the test case from hell, TestSort.java, has majorly >>>> changed again and test_Sort.py needs to be ported again. Sigh. >>> >>> That being said, you should be able to build PyLucene 4.1 again and proceed >>> with FacetExample.py. The test_Sort.py needed work shouldn't be blocking >>> you. >>> >>> Andi.. >> >>