Yep, that looks like a bug... I'll look at your solution and fix it! Best, Mattias
2011/1/13 向雅 <fya...@gmail.com> > Index: LuceneIndex.java > =================================================================== > --- LuceneIndex.java (版本 8273) > +++ LuceneIndex.java (工作副本) > @@ -242,7 +242,8 @@ > Collection<IndexHits<Long>> iterators = new > ArrayList<IndexHits<Long>>(); > iterators.add( searchedIds ); > iterators.add( new > ConstantScoreIterator<Long>( ids, Float.NaN ) ); > - idIterator = new CombinedIndexHits<Long>( > iterators ); > +// idIterator = new CombinedIndexHits<Long>( > iterators ); > + idIterator = new ConstantScoreIterator<Long>( > ids, Float.NaN ) ; > } > } > } > > from context logic, because ids already not empty, so just use it directly. > I change the idIterator, seems it work fine. my test greened. > > 致敬 > 向雅 > > > > 2011/1/14 向雅 <fya...@gmail.com>: > > I updated trunk, > > > > svn diff -r 7126 LuceneIndex.java > > Index: LuceneIndex.java > > =================================================================== > > --- LuceneIndex.java (版本 7126) > > +++ LuceneIndex.java (工作副本) > > @@ -216,7 +216,7 @@ > > IndexSearcherRef searcher = null; > > try > > { > > - searcher = service.dataSource().getIndexSearcher( identifier > ); > > + searcher = service.dataSource().getIndexSearcher( > > identifier, true ); > > if ( searcher != null ) > > { > > boolean foundInCache = false; > > @@ -255,7 +255,7 @@ > > } > > > > idIterator = idIterator == null ? new > > ConstantScoreIterator<Long>( ids, 0 ) : idIterator; > > - return new IdToEntityIterator<T>( idIterator, searcher ) > > + return new IdToEntityIterator<T>( idIterator ) > > { > > @Override > > protected T underlyingObjectToObject( Long id ) > > @@ -300,7 +300,6 @@ > > { > > try > > { > > - searcher.incRef(); > > IndexHits<Document> result = null; > > if ( additionalParametersOrNull != null && > > additionalParametersOrNull.topHits > 0 ) > > { > > > > seems the IdToEntityIterator constructor should use invocation before > version. > > because new version IdToEntityIterator object currentiterator() always > > null before fetch operation. > > > > 致敬 > > 向雅 > > > > > > > > 2011/1/14 Balazs E. Pataki <pat...@dsd.sztaki.hu>: > >> Oh, and it happens with neo4j 1.2. > >> --- > >> balazs > >> > >> On 1/13/11 4:38 PM, Balazs E. Pataki wrote: > >>> Hi, > >>> > >>> under certain circumstances (which I could not yet reproduce in a > simple > >>> example) I get this exception from Lucene while searching for a simple > >>> key=value: > >>> > >>> IndexHits<Node> hits = index.get(OID_PROP, oid); > >>> if (hits.size() == 0) { > >>> ... > >>> } > >>> > >>> > >>> Caused by: java.lang.NullPointerException > >>> at > >>> > org.neo4j.index.impl.lucene.CombinedIndexHits.size(CombinedIndexHits.java:53) > >>> at > >>> > org.neo4j.index.impl.lucene.IdToEntityIterator.size(IdToEntityIterator.java:72) > >>> > >>> > >>> As far as I coudl track down this problem, it is not really related to > >>> Lucene indexing, rather a problem with a neo4j class: > >>> > >>> The problem seems to be with the following LuceneIndex method > >>> > >>> protected IndexHits<T> query( Query query, String > keyForDirectLookup, > >>> Object valueForDirectLookup, QueryContext > >>> additionalParametersOrNull ) > >>> { > >>> ... > >>> idIterator = new CombinedIndexHits<Long>( iterators ); > >>> ... > >>> } > >>> > >>> It creates a CombinedIndexHits and will return this to my query() call. > >>> > >>> CombinedIndexHits is a CombiningIterator initialized wih the > "iterators" > >>> above like this: > >>> > >>> public CombiningIterator( Iterable<? extends Iterator<T>> > iterators ) > >>> { > >>> this.iterators = iterators.iterator(); > >>> } > >>> > >>> Now, when I get back the IndexHits (a CombinedIndexHits actually) I > >>> first invoke size() on it which in turn will call > >>> > >>> CombiningIterator#currentIterator(): > >>> > >>> protected Iterator<T> currentIterator() > >>> { > >>> return currentIterator; > >>> } > >>> > >>> And this will be null when CombiningIterator is constructed with > >>> CombiningIterator( Iterable<? extends Iterator<T>> iterators ). > >>> > >>> To make it work it probably needs: > >>> > >>> public CombiningIterator( Iterable<? extends Iterator<T>> > iterators ) > >>> { > >>> this.iterators = iterators.iterator(); > >>> currentIterator = this.iterators.next(); > >>> } > >>> > >>> Could you please confirm that it is indeed a bug in > >>> LucenIndex/CombinedIndexHits/CombiningIterator or should I look for > >>> something else I do bad with my indexes? > >>> > >>> Thanks in advance! > >>> --- > >>> balazs > >>> _______________________________________________ > >>> Neo4j mailing list > >>> User@lists.neo4j.org > >>> https://lists.neo4j.org/mailman/listinfo/user > >> _______________________________________________ > >> Neo4j mailing list > >> User@lists.neo4j.org > >> https://lists.neo4j.org/mailman/listinfo/user > >> > > > _______________________________________________ > Neo4j mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user > -- Mattias Persson, [matt...@neotechnology.com] Hacker, Neo Technology www.neotechnology.com _______________________________________________ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user