You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Trejkaz (JIRA)" <ji...@apache.org> on 2015/10/07 05:36:26 UTC

[jira] [Updated] (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:all-tabpanel ]

Trejkaz updated LUCENE-6826:
----------------------------
    Attachment: Lucene6826.java

This test creates an index with one document which contains a value which does not match the filter. It then migrates the index in a fashion that just filters out the values, we don't want, which becomes all values in that field, which triggers the error.

The first half of the day I tried to reproduce the exact same thing from scratch with no success - it happily migrated. This version comes from working code, simplified as far as possible without removing the issue, so it could turn out that there is a subtle bug in my code as well.


> 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
>         Attachments: Lucene6826.java
>
>
> 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