When doing some analytics on our search index to see if we can reduce the number of fields, I came across a problem where fields set to hidden within our content type display still wind up being indexed by SOLR. This is only valid for fields treated as such in SOLR, like taxonomy and boolean checkboxes.

To reproduce:

* Download and install apachesolr 7.x-1.x
* On any content type, add a boolean field and save.
* Go into manage displays for that content type. Verify your new field above is marked as "<Hidden>" under format
* Go into any node of that type, set a value for the new hidden field and save
* Go into your Apache SOLR index settings and reindex the updated node
* Using the out-of-the-box SOLR admin UI, look at the node you just indexed; you will see the hidden field show up.

Attached is a patch that fixes this; a simple typo in a conditional:

$instances[$bundle][$field_name]['display']['search_index'] != 'hidden'

... search_index is an array so it will always evaluate to true.

Let me know if more detail is needed.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

blazindrop’s picture

Status: Active » Needs review
FileSize
799 bytes
Nick_vh’s picture

+++ b/apachesolr.moduleundefined
@@ -2055,7 +2055,7 @@ function apachesolr_entity_fields($entity_type = 'node') {
+          if (empty($instances[$bundle][$field_name]['display']['search_index']) || $instances[$bundle][$field_name]['display']['search_index']['type'] != 'hidden') {

if this is true, we should check if the ['type'] is not empty :)

blazindrop’s picture

Rolled another patch with Nick's suggestions aftering chatting in IRC. I did add some extra code to avoid having the line wrap. Works good locally.

Status: Needs review » Needs work

The last submitted patch, apachesolr-hidden_display_indexed-1977832-3.patch, failed testing.

blazindrop’s picture

Status: Needs work » Needs review
FileSize
928 bytes

Reattaching recreated patch.

blazindrop’s picture

Any thoughts on my previous comments? I imagine this is a pretty big issue because of the potential sensitivity of information behind hidden fields, not to mention the performance and memory improvements by not indexing hidden fields.

pwolanin’s picture

Version: 7.x-1.x-dev » 6.x-3.x-dev
Status: Needs review » Patch (to be ported)

Looks good to me. Committed to 7.x. Need to check 6.x-3.x

pwolanin’s picture

Issue summary: View changes

encode angle brackets