lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marcin T <>
Subject Problem enum type field
Date Sat, 09 Sep 2017 10:52:32 GMT

In my project i use Apache Solr version 6.2.1. A schema.xml contains
an enum field. When I try to index this field (sending a java object
with an enum via solrj) I get an exception (stacktrace below)

Error from server at Unknown value for
enum field: <class_name>:<enum_name>
        at org.apache.solr.client.solrj.impl.HttpSolrClient.executeMethod(
        at org.apache.solr.client.solrj.impl.HttpSolrClient.request(
        at org.apache.solr.client.solrj.impl.HttpSolrClient.request(
        at org.apache.solr.client.solrj.impl.LBHttpSolrClient.doRequest(
        at org.apache.solr.client.solrj.impl.LBHttpSolrClient.request(
        at org.apache.solr.client.solrj.impl.CloudSolrClient.sendRequest(
        at org.apache.solr.client.solrj.impl.CloudSolrClient.requestWithRetryOnStaleState(
        at org.apache.solr.client.solrj.impl.CloudSolrClient.request(
        at org.apache.solr.client.solrj.SolrRequest.process([100:org.apache.servicemix.bundles.solr-solrj:]
        at org.apache.solr.client.solrj.SolrClient.add([100:org.apache.servicemix.bundles.solr-solrj:]
        at org.apache.solr.client.solrj.SolrClient.addBeans([100:org.apache.servicemix.bundles.solr-solrj:]
        at org.apache.solr.client.solrj.SolrClient.addBeans([100:org.apache.servicemix.bundles.solr-solrj:]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
        at sun.reflect.NativeMethodAccessorImpl.invoke([:1.8.0_51]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke([:1.8.0_51]
        at java.lang.reflect.Method.invoke([:1.8.0_51]

It looks like solrj cannot properly handle an enum field. While code
debugging I have noticed that there is a writeVal(Object) method in
org.apache.solr.common.util.JavaBinCodec class, which is responsible
for serialization a java object to a bytes. This methods ends with a
fallback code

writeVal(val.getClass().getName() + ':' + val.toString());

which, in case when field type is unknown, field is serialize as
string <class_name>:<enum_name> (this is my case).

When I convert enum to string all works fine but I don't want do that.

How can I properly send a java object which contains an enum field to
solr via solrj?

Best regards,

View raw message