NPE during call IndexWriter.updateDocument(idTerm, doc); [LUCENE-5846]
- Dominant language
- Java
- Stars
- 3.6k
- Forks
- 1.4k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 88
Description
stack trace:
java.lang.NullPointerException
at org.apache.lucene.document.Field.tokenStream(Field.java:552)
at org.apache.lucene.index.DocInverterPerField.processFields(DocInverterPerField.java:103)
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:455)
at org.apache.lucene.index.IndexWriter.updateDocument(IndexWriter.java:1534)
at org.apache.lucene.index.IndexWriter.updateDocument(IndexWriter.java:1507)
at com.my.search.requesthandler.EnrichingUpdateHandler.updateTransitiveEntities(EnrichingUpdateHandler.java:108)
at com.my.search.requesthandler.EnrichingUpdateHandler.addDoc(EnrichingUpdateHandler.java:68)
at org.apache.solr.update.processor.RunUpdateProcessor.processAdd(RunUpdateProcessorFactory.java:69)
at org.apache.solr.update.processor.UpdateRequestProcessor.processAdd(UpdateRequestProcessor.java:51)
at org.apache.solr.update.processor.DistributedUpdateProcessor.versionAdd(DistributedUpdateProcessor.java:730)
at org.apache.solr.update.processor.DistributedUpdateProcessor.processAdd(DistributedUpdateProcessor.java:557)
at org.apache.solr.update.processor.LogUpdateProcessor.processAdd(LogUpdateProcessorFactory.java:100)
at org.apache.solr.handler.dataimport.SolrWriter.upload(SolrWriter.java:70)
at org.apache.solr.handler.dataimport.DataImportHandler$1.upload(DataImportHandler.java:235)
at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:512)
at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:416)
at org.apache.solr.handler.dataimport.DocBuilder.doDelta(DocBuilder.java:365)
at org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:231)
at org.apache.solr.handler.dataimport.DataImporter.doDeltaImport(DataImporter.java:444)
at org.apache.solr.handler.dataimport.DataImporter.runCmd(DataImporter.java:485)
at org.apache.solr.handler.dataimport.DataImporter$1.run(DataImporter.java:464)
During debugging I found that all string field types has property tokenized=true, while default org.apache.lucene.document.StringField.TYPE_STORED has tokenized=false (in schema.xml I used type "string", not "text"). Wrong(as for me) field type was set in org.apache.lucene.document.DocumentStoredFieldVisitor.stringField(...)
line 69: final FieldType ft = new FieldType(TextField.TYPE_STORED);
Setting tokenized=true caused wrong(IMHO) flow in org.apache.lucene.document.Field.tokenStream(Analyzer analyzer) - condition !fieldType().tokenized() not passed.
Setting tokenized=false using reflection fixed problem, but it's a hack:)
Problem and it's root cause are my assumptions and could be just misconfiguration, so please re-check it
---
Migrated from [LUCENE-5846](https://issues.apache.org/jira/browse/LUCENE-5846) by Konstantin Nazarenkov
Contributor guide
Research direction
Start at org.apache.lucene.document.DocumentStoredFieldVisitor.stringField(...) around line 69, then trace the resulting FieldType through Field.tokenStream(Analyzer). Compare this path with StringField.TYPE_STORED and the reported IndexWriter.updateDocument(idTerm, doc) entry point; done means the NPE cause and intended tokenization behavior are confirmed and covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- search
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100