Inconsistent index options = DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS error after upgrade

Created on 30 September 2023, 9 months ago
Updated 8 October 2023, 9 months ago

I found a solution to the problem, so I am only posting in case anyone else encounters this situation.

After updating Search API Solr from 4.2.12 to 4.3 I was getting an odd error when I tried to index:

$ drush search-api:reset-tracker && drush search-api:index
>  [error]  Drupal\search_api_solr\SearchApiSolrException while indexing item entity:node/101:en: Solr endpoint http://solr:8983/ bad request (code: 400, body: Exception writing document id 24a5te-solr_index-entity:node/101:en to the index; possible analysis error: cannot change field "tm_X3b_en_title" from index options=DOCS_AND_FREQS_AND_POSITIONS to inconsistent index options=DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS, message: Solr HTTP error: OK (400)

I tried a few things, and am not sure which of them worked, but here they are:

  • Cleared all data in Solr with this command, this is probably what solved it. Replace mysite with the name of your DDEV instance and solrcore with your Solr core machine name:

    curl -X POST -H 'Content-Type: application/json' --data-binary '{"delete":{"query":"*:*" }}' http://mysite.ddev.site:8983/solr/solrcore/update

    From https://solr.apache.org/guide/solr/latest/indexing-guide/reindexing.html

  • I noticed these values for the "Configured" and "Detected" Server (/admin/config/search/search-api/server/solr_server):

    Configured Solr Version 8.0.0
    Detected Solr Version 8.11.2

    So I updated "Server" > "Connector Workarounds" > "Solr version override" from 8.x to Determine automatically, and they now match.

    Configured Solr Version 8.11.2
    Detected Solr Version 8.11.2

    I re-uploaded the Solr config and restarted DDEV to make it take effect.

  • Reset tracker and re-indexed successfully:

    $ drush search-api:reset-tracker
    $ drush search-api:index
    

The full error message

$ drush search-api:reset-tracker && drush search-api:index
>  [error]  Drupal\search_api_solr\SearchApiSolrException while indexing item entity:node/101:en: Solr endpoint http://solr:8983/ bad request (code: 400, body: Exception writing document id 24a5te-solr_index-entity:node/101:en to the index; possible analysis error: cannot change field "tm_X3b_en_title" from index options=DOCS_AND_FREQS_AND_POSITIONS to inconsistent index options=DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS, message: Solr HTTP error: OK (400)
> {
>   "responseHeader":{
>     "status":400,
>     "QTime":2},
>   "error":{
>     "metadata":[
>       "error-class","org.apache.solr.common.SolrException",
>       "root-error-class","java.lang.IllegalArgumentException"],
>     "msg":"Exception writing document id 24a5te-solr_index-entity:node/101:en to the index; possible analysis error: cannot change field \"tm_X3b_en_title\" from index options=DOCS_AND_FREQS_AND_POSITIONS to inconsistent index options=DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS",
>     "code":400}}
> ). in Drupal\search_api_solr\SolrConnector\SolrConnectorPluginBase->handleHttpException() (line 1089 of /var/www/html/web/modules/contrib/search_api_solr/src/SolrConnector/SolrConnectorPluginBase.php). 
>  [error]  Drupal\search_api_solr\SearchApiSolrException while indexing item entity:node/147:en: Solr endpoint http://solr:8983/ bad request (code: 400, body: Exception writing document id 24a5te-solr_index-entity:node/147:en to the index; possible analysis error: cannot change field "tm_X3b_en_title" from index options=DOCS_AND_FREQS_AND_POSITIONS to inconsistent index options=DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS, message: Solr HTTP error: OK (400)
πŸ“Œ Task
Status

Closed: works as designed

Version

4.0

Component

Documentation

Created by

πŸ‡©πŸ‡°Denmark ressa Copenhagen

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @ressa
  • πŸ‡©πŸ‡°Denmark ressa Copenhagen
  • πŸ‡©πŸ‡°Denmark ressa Copenhagen
  • πŸ‡©πŸ‡°Denmark ressa Copenhagen
  • πŸ‡©πŸ‡°Denmark ressa Copenhagen
  • πŸ‡©πŸ‡ͺGermany mkalkbrenner πŸ‡©πŸ‡ͺ

    From the release notes:

    In order to support advanced highlighting and other features, the Solr schema provided by Search API Solr 4.3 got some fundamental changes, for example the usage of StandardTokenizer and storeOffsetsWithPositions.
    When you upgrade the module to 4.3.x from 4.2.x and earlier you still can read an existing Solr index and perform searches.
    But if you write (index) data you'll run into errors like cannot change field "xyz" from index options=DOCS_AND_FREQS_AND_POSITIONS to inconsistent index options=DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS.
    There're different ways to deal with the required update. But all require Solr knowledge.
    But the safest way is to delete the existing core (or collection in case of Solr Cloud) and to create a new core (or collection) using a new Solr config-set generated by Search API Solr 4.3.x and to re-index your data afterwards.
    If you want to avoid downtime of your service, you can also create a new core (or collection), clone and adjust the Search API server and index configs and index all your data twice, while users can still search via the old core (or collection). Afterwards you can use Solr's rename or alias capabilities to switch both cores (or collections) and delete the cloned Search API server and index configs.

  • πŸ‡©πŸ‡°Denmark ressa Copenhagen

    Thanks for clarifying what the problem and solution is, and updating the Release Note with a section about it today.

  • πŸ‡ΊπŸ‡ΈUnited States SomebodySysop

    I have a question about creating a new core.

    This is my normal process:

    from /var/solr/data:

    mkdir newCore
    mkdir newCorei/data
    cp -fr oldCore/conf/ newCore

    Then create the core in the Solr dashboard and "Add Core"

    Sounds like the only thing different about this process will be to upload the configuration files from configs.zip to newCore/conf instead of copying them from oldCore.

Production build 0.69.0 2024