Does not index new boolean fields on existing content

Created on 17 May 2023, about 2 years ago

Respect the submission guidelines above! Drupal.org issue forks cause additional work for the project maintainer!

Setup

  • Solr version: 7.7.3
  • Drupal Core version: 9.3.22
  • Search API version: 8.x-1.28
  • Search API Solr version: 4.2.7
  • Configured Solr Connector: Standard

Issue

  1. Create some content and index it.
  2. Add a new boolean field to the content type.
  3. Add the new boolean field to the search index, and reindex the content.
  4. None of the existing content will have this boolean field in the indexed document. Only new content or content that gets re-saved will have a value for it.
  5. This means in a view, you cannot use this new boolean field in a filter, because adding the filter will cause no content at all to appear. The only options for the filter are true and false, but most of the content has no value.

Expected results

  1. When indexing content, if a boolean field doesn't have a value on the node (i.e. it's null) then this should be indexed as false in Solr.
  2. When adding a filter to a view on a boolean field, nodes with no value for that field should be considered as not having it checked (i.e. not true).

🐛 Bug report
Status

Active

Version

4.2

Component

Code

Created by

🇬🇧United Kingdom Rob230

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

Comments & Activities

  • Issue created by @Rob230
  • 🇩🇪Germany mkalkbrenner 🇩🇪

    When indexing content, if a boolean field doesn't have a value on the node (i.e. it's null) then this should be indexed as false in Solr.

    This expectation is wrong. Null means that the field is not stored in the index!
    You need to write an update hook that updates your existing code to set the field value to false.
    But that's standard Drupal.

  • Status changed to Fixed about 2 years ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

  • That doesn't make any sense.

    Why wouldn't you just be able to filter on: Not equal to - True?

  • Status changed to Fixed about 6 hours ago
  • 🇩🇰Denmark ressa Copenhagen

    Just adding a comment that I also saw a slightly strange behaviour, where a Boolean field was added to the index, but not present after re-indexing. I tried changing Type to String, and some other stuff, but then deleted and added the field again, and this time it got indexed as expected, with bs_field_main_image:true, ¯\_(ツ)_/¯

Production build 0.71.5 2024