Drupal 6.x strings and integers

Drupal

The Problem

Drupal 6.x ships Solr config files with a known bug: numeric and floating-point values are wrapped in <str> tags instead of <int> and <float> tags. Solr expects the correct XML types and will throw errors or behave unpredictably when it gets strings where it expects numbers.

DRUPAL 6.x XML TYPE BUGWRONG (Drupal Default)<str name="maxEdits">2</str>String wrapping a number = errorsCORRECT (Fixed)<int name="maxEdits">2</int>Proper type = works perfectlyRule: whole numbers → <int> | decimals → <float> | text → <str>Fix the tags in solrconfig_extra.xml, save, and Reload your Opensolr Index.


What Is Wrong

In solrconfig_extra.xml (and possibly other Drupal config files), you will find entries like this:

<!-- WRONG: integers and floats wrapped as strings -->
<str name="accuracy">0.5</str>
<str name="maxEdits">2</str>
<str name="minPrefix">1</str>
<str name="maxInspections">5</str>
<str name="minQueryLength">4</str>
<str name="maxQueryFrequency">0.01</str>
<str name="thresholdTokenFrequency">.01</str>

These should use the correct XML types based on their values:

<!-- CORRECT: proper types for each value -->
<float name="accuracy">0.5</float>
<int name="maxEdits">2</int>
<int name="minPrefix">1</int>
<int name="maxInspections">5</int>
<int name="minQueryLength">4</int>
<float name="maxQueryFrequency">0.01</float>
<float name="thresholdTokenFrequency">.01</float>

How to Fix It

  1. Open your Opensolr Index Control Panel
  2. Go to the Config Files Editor
  3. Select solrconfig_extra.xml
  4. Find all <str> tags that contain numeric values
  5. Change <str> to <int> for whole numbers and <float> for decimal numbers
  6. Save and Reload your Opensolr Index

Also check other Drupal config files (solrconfig.xml, schema_extra_types.xml) for the same issue — this bug may appear in multiple places across different Drupal Solr versions.


Quick Reference

Value Type Correct Tag Example
Whole number (2, 5, 100) <int> <int name="maxEdits">2</int>
Decimal number (0.5, 0.01) <float> <float name="accuracy">0.5</float>
Text string ("hello") <str> <str name="field">suggest_field</str>

Need help fixing Drupal config files? Reach out to us at support@opensolr.com — we can correct these issues for you instantly.