lucene-pylucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andi Vajda <va...@apache.org>
Subject Re: FacetExample.py
Date Tue, 12 Feb 2013 21:36:14 GMT

  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 <vajda@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..
>
>

Mime
View raw message