[ 
https://issues.apache.org/jira/browse/LUCENE-5367?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13856264#comment-13856264
 ] 

Lucien Pereira commented on LUCENE-5367:
----------------------------------------

Shai,

Sorry for the delay. It it happens when a given document is added several times 
:

{code:title=Lucene5367.java|borderStyle=solid}
package testcase;

import java.io.File;
import java.util.List;

import org.apache.lucene.analysis.core.KeywordAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.facet.index.FacetFields;
import org.apache.lucene.facet.taxonomy.CategoryPath;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.NIOFSDirectory;
import org.apache.lucene.util.Version;

public class Lucene5367 {

        public static void main(String[] args) throws Exception {
                Directory indexDirectory = new NIOFSDirectory(new 
File("~/index"));
                Directory taxonomyDirectory = new NIOFSDirectory(new 
File("~/taxonomy"));
                Document document = new Document();
                IndexWriter indexWriter = new IndexWriter(indexDirectory,
                                new IndexWriterConfig(Version.LUCENE_46, new 
KeywordAnalyzer()));
                DirectoryTaxonomyWriter taxonomyWriter = new 
DirectoryTaxonomyWriter(
                                taxonomyDirectory);
                List<CategoryPath> categories = java.util.Collections
                                .singletonList(new CategoryPath("home", 
"root"));
                FacetFields facetFields = new FacetFields(taxonomyWriter);

                facetFields.addFields(document, categories);

                taxonomyWriter.close();
                indexWriter.addDocument(document);
                indexWriter.addDocument(document);

                indexWriter.close();
        }
}
{code}

Regards,
Lucien

> NoSuchElementException occurs when org.apache.lucene.facet.index.FacetFields 
> is used.
> -------------------------------------------------------------------------------------
>
>                 Key: LUCENE-5367
>                 URL: https://issues.apache.org/jira/browse/LUCENE-5367
>             Project: Lucene - Core
>          Issue Type: Bug
>          Components: modules/facet
>    Affects Versions: 4.2.1, 4.6
>            Reporter: Lucien Pereira
>
> Hi,
> When I use the API as below :
> {code}
> List<CategoryPath> categories = Collections.<CategoryPath>singletonList(new 
> CategoryPath(path.toArray(new String[path.size()])));
> FacetFields facetFields = new FacetFields(taxonomyWriter);
> facetFields.addFields(document, categories);
> taxonomyWriter.commit();
> {code}
> An exception occurs :
> {quote}
> java.util.NoSuchElementException
>       at java.util.Collections$1.next(Collections.java:3302)
>       at 
> org.apache.lucene.facet.index.DrillDownStream.reset(DrillDownStream.java:78)
>       at 
> org.apache.lucene.index.DocInverterPerField.processFields(DocInverterPerField.java:97)
>       at 
> org.apache.lucene.index.DocFieldProcessor.processDocument(DocFieldProcessor.java:248)
>       at 
> org.apache.lucene.index.DocumentsWriterPerThread.updateDocument(DocumentsWriterPerThread.java:253)
>       at 
> org.apache.lucene.index.DocumentsWriter.updateDocument(DocumentsWriter.java:453)
>       at 
> org.apache.lucene.index.IndexWriter.updateDocument(IndexWriter.java:1520)
>       at 
> org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:1190)
>       at 
> org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:1171)
> {quote}
> Seems likes this is due to multiple calls to 
> org.apache.lucene.facet.index.DrillDownStream#reset which invoques #next() on 
> an 'used' iterator.
> Regards,
> Lucien 



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to