Solr DataImportHandler CachedSqlEntityProcessor ClassCastException

前端 未结 5 1661
[愿得一人]
[愿得一人] 2021-01-21 08:49

I am using Solr 4.6.0 and trying to import my data using CachedSqlEntityProcessor, but somehow I end up getting a ClassCastException.

5条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-21 09:24

    This is a matter of case. You need to write the key in the cacheLookup attribute in upper-case. If you use

    cacheLookup="publication.CONFERENCE_ID"
    

    it will work.

    All columns you gather for the entity publication are gathered within a Map internally. The keys to that map are uppercased. When you write cacheLookup="publication.CONFERENCE_ID" that short part after the equals sign publication.CONFERENCE_ID is a short-cut to that map. Apparently a String#toUpper is missing at some point in between.


    I have added a test case about this, have a look at the DIHCachedTest, check it out and let it run. You will need maven for this. I create an embedded HSQLDB that mimics your schema and run an embedded Solr that does have 2 data-import configurations.

    • src/main/resources/solr/dih-cached/conf/data-config-fault.xml
    • src/main/resources/solr/dih-cached/conf/data-config.xml

    The first one is used for the test case DIHCachedTest#runImportWithFault. This will run into the same error you have posted in your question.

    The second one is used for the test case DIHCachedTest#runImport. This will succeed.

    If you compare both configurations, you will see that the only difference is the case of cacheLookup="publication.CONFERENCE_ID" vs cacheLookup="publication.conference_id".


    The issue SOLR-2483 DIH - an uppercase problem in query parameters describes this bug pattern.

提交回复
热议问题