You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Michael McCandless (JIRA)" <ji...@apache.org> on 2015/10/06 10:44:27 UTC
[jira] [Commented] (LUCENE-6826) java.lang.ClassCastException:
org.apache.lucene.index.TermsEnum$2 cannot be cast to
org.apache.lucene.index.MultiTermsEnum when adding indexes
[ https://issues.apache.org/jira/browse/LUCENE-6826?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14944708#comment-14944708 ]
Michael McCandless commented on LUCENE-6826:
--------------------------------------------
Hmm, no good ... I think we first need a small test case exposing this.
I think it should only happen if you have a {{FilterCodecReader}} that has filters a field by providing no terms in the {{TermsEnum}}?
I.e. I think Lucene (at least the default codec) would normally not write a field if it has 0 terms.
> 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-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org