cannot change DocValues type from SORTED to SORTED_SET – DataStax Graph – Titan – Solr

cannot change DocValues type from SORTED to SORTED_SET – DataStax Graph – Titan – Solr

Are you facing these errors???

  1. cannot change docvalues type from sorted_set to sorted for field field_name
  2. cannot change docvalues type from sorted to sorted_set for field field_name

No worries. We have the solution. First of all we need to know what DocValues means in Solr. You will find a lot of information in the internet. Now we will see why we are getting the error “cannot change DocValues type from SORTED_SET to SORTED for field field_name”.

Lets us consider we have a field named description with type solr.TextField with docValues property true. We will now have a separate data stored which is meant for performing efficient faceting, sorting and other operations. In order to support search requirements, we want to change the type to some other existing Solr supported types or even custom type. So basically we will update the vertex label schema and reindex the data. In this process, Solr will try to reindex the data with new schema changes. What If the field data values of the older field type is not compatible with the newer field type? Yes we get error in this case. So what is the solution? 

Solution:

  1. Update the field data type and disable DocValues
  2. Reindex Data
  3. Enable DocValue
  4. Reindex Data
  5. That’s it

Steps:

Step 1:

Execute the following queries in the server.

dsetool get_core_config {{GRAPH_NAME}}.{{VERTEX_LABEL}}_p > {{VERTEX_LABEL}}_config.xml

dsetool get_core_schema {{GRAPH_NAME}}.{{VERTEX_LABEL}}_p > {{VERTEX_LABEL}}_schema.xml

E.g.

dsetool get_core_config TESTGRAPH.TESTLABEL_p > TESTLABEL_config.xml

dsetool get_core_schema TESTGRAPH.TESTLABEL_p > TESTLABEL_schema.xml

The above two queries will create a config file and a schema file for the given vertex label. Take backup of the config and schema file.

Step 2:

Open the schema file TESTLABEL_schema.xml. You will find some similar to the following line.

<field docValues="true" indexed="true" multiValued="false"
name="description" stored="true" type="StrField"/>

Update the docValues property to false and save the file. Make sure you update the field data type which you want to change which is description in our case.

Step 3:

Execute the following command which will clear the existing docValues data.

dsetool reload_core TESTGRAPH.TESTLABEL_p reindex=true
schema=TESTLABEL_schema.xml solrconfig=TESTLABEL_config.xml

Step 4:

Open the schema file TESTLABEL_schema.xml. Update the docValues property to true and save the file.

Step 5:

Execute the following command which will create the required docValues data.

dsetool reload_core TESTGRAPH.TESTLABEL_p reindex=true
schema=TESTLABEL_schema.xml solrconfig=TESTLABEL_config.xml

Step 6:

Enjoy!!!

[ YOU MAY ALSO LIKE ]

Leave a Reply