Problem enum type field

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Problem enum type field

Marcin T
HI,

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)

org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException:
Error from server at http://mydomain.pl/solr/text: Unknown value for
enum field: <class_name>:<enum_name>
        at org.apache.solr.client.solrj.impl.HttpSolrClient.executeMethod(HttpSolrClient.java:560)
        at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:235)
        at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:227)
        at org.apache.solr.client.solrj.impl.LBHttpSolrClient.doRequest(LBHttpSolrClient.java:376)
        at org.apache.solr.client.solrj.impl.LBHttpSolrClient.request(LBHttpSolrClient.java:328)
        at org.apache.solr.client.solrj.impl.CloudSolrClient.sendRequest(CloudSolrClient.java:1086)
        at org.apache.solr.client.solrj.impl.CloudSolrClient.requestWithRetryOnStaleState(CloudSolrClient.java:856)
        at org.apache.solr.client.solrj.impl.CloudSolrClient.request(CloudSolrClient.java:799)
        at org.apache.solr.client.solrj.SolrRequest.process(SolrRequest.java:135)[100:org.apache.servicemix.bundles.solr-solrj:5.2.1.1]
        at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:107)[100:org.apache.servicemix.bundles.solr-solrj:5.2.1.1]
        at org.apache.solr.client.solrj.SolrClient.addBeans(SolrClient.java:358)[100:org.apache.servicemix.bundles.solr-solrj:5.2.1.1]
        at org.apache.solr.client.solrj.SolrClient.addBeans(SolrClient.java:330)[100:org.apache.servicemix.bundles.solr-solrj:5.2.1.1]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)[:1.8.0_51]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)[:1.8.0_51]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.8.0_51]
        at java.lang.reflect.Method.invoke(Method.java:497)[: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,
Marcin