Trejkaz created LUCENE-6826:
-------------------------------

             Summary: java.lang.ClassCastException: 
org.apache.lucene.index.TermsEnum$2 cannot be cast to 
org.apache.lucene.index.MultiTermsEnum when adding indexes
                 Key: LUCENE-6826
                 URL: https://issues.apache.org/jira/browse/LUCENE-6826
             Project: Lucene - Core
          Issue Type: Bug
          Components: core/index
    Affects Versions: 5.2.1
            Reporter: Trejkaz


We are using addIndexes and FilterCodecReader tricks as part of index migration.

Whether FilterCodecReader tricks are required to reproduce this is uncertain, 
but in any case, when migrating a particular index, I saw this exception:

{noformat}
java.lang.ClassCastException: org.apache.lucene.index.TermsEnum$2 cannot be 
cast to org.apache.lucene.index.MultiTermsEnum
        at 
org.apache.lucene.index.MappedMultiFields$MappedMultiTerms.iterator(MappedMultiFields.java:65)
        at 
org.apache.lucene.codecs.blocktree.BlockTreeTermsWriter.write(BlockTreeTermsWriter.java:426)
        at 
org.apache.lucene.codecs.perfield.PerFieldPostingsFormat$FieldsWriter.write(PerFieldPostingsFormat.java:198)
        at 
org.apache.lucene.codecs.FieldsConsumer.merge(FieldsConsumer.java:105)
        at 
org.apache.lucene.index.SegmentMerger.mergeTerms(SegmentMerger.java:193)
        at org.apache.lucene.index.SegmentMerger.merge(SegmentMerger.java:95)
        at org.apache.lucene.index.IndexWriter.addIndexes(IndexWriter.java:2519)
{noformat}

TermsEnum$2 appears to be TermsEnum.EMPTY. The place where it creates it is 
here:

MultiTermsEnum#reset:
{code}
    if (queue.size() == 0) {
      return TermsEnum.EMPTY;   // <- this is not a MultiTermsEnum
    } else {
      return this;
    }
{code}

A quick hack would be for MappedMultiFields to check for TermsEnum.EMPTY 
specifically before casting, but there might be some way to avoid the cast 
entirely and that would obviously be a better idea.




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to