6

This is for Sitecore 8.1 Update 3, using Solr 5.5.

It appears that in a Multilist with Search Field, if the field has two or more items currently selected (it does not matter whether the item has been saved or not), the search request that is sent ends up generating an improper Solr query that causes no results to be returned.

For example, here is a query that is generated when trying to perform a search on the field:

((-_group:(8ef752a6793c446d849aa5a0b455457a) AND -_group:(da0d9a141798455da6a66994742e48c8)) AND ((((_content:(roger) OR _name:(roger) OR _displayname:(roger)) AND _path:(79e09ae03e614e069349b05ca2aada81)) AND _template:(8904e4c272604056b65ddb881a06de95)) AND _latestversion:(True)))

It's the first grouping that is attempting to exclude already selected items within the field that causes this search to fail. We can manually modify the query to "fix" it and return what we want:

  1. First we can negate the grouping

    -((-_group:(8ef752a6793c446d849aa5a0b455457a) AND -_group:(da0d9a141798455da6a66994742e48c8)) AND ((((_content:(roger) OR _name:(roger) OR _displayname:(roger)) AND _path:(79e09ae03e614e069349b05ca2aada81)) AND _template:(8904e4c272604056b65ddb881a06de95)) AND _latestversion:(True)))

  2. Or we can arrange the grouping to be "correct":

    ( -_group:(beff3037e34941e4ae4608d7524118df) AND -_group:(a5b7d1a6f38148189f0f88aeb84162fc) AND -_group:(26e8bb2e727746c89c2577dda04afa54) AND -_group:(c4ff9b4b053d4e749758ec1261f35124) AND ((((_content:(roger) OR _name:(roger) OR _displayname:(roger)) AND _path:(79e09ae03e614e069349b05ca2aada81)) AND _template:(8904e4c272604056b65ddb881a06de95)) AND _latestversion:(True)) )

Essentially, Sitecore is incorrectly grouping the "_group" fields together so this problem will only show up when one more than one item is selected.

I've fixed this issue for now by modifying the client side javascript to no longer send the selected id's to the search handler:

\sitecore\shell\Controls\BucketList\BucketList.js, line 140

self.getSelectedIdsFilter = function (){
    return "";
    //return [].slice.call($(self.clientId + '_selected').options, 0)
    //    .map(function (option) { return "&-id=" + option.value })
    //    .join('');
 };

Doing the above modification to the client-side JS allows me to correctly search on a Multilist with Search field. However, I consider it a hack and was wondering if anyone had a "proper" solution to this problem? I looked into overriding the default search handler, but the "problem code" that is responsible for taking the search request and parsing it into a solr query seemed especially difficult to replace/modify due to how it was architected. .

6

There are a number of known issues with the Sitecore Multilist with Search field type especially with Sitecore 8.

Sitecore provide a workaround with a new Field Type called the AdvancedSearchList. You can download it here:

https://kb.sitecore.net/articles/372032

  • 1
    Thanks for the information! Was not expecting a "Yeah, don't use that field" from Sitecore! I'll be sure to use the AdvancedSearchList field type moving forward (although moving everything over from a Multilist with Search will present it's own challenges). – Justin Laster Oct 12 '16 at 14:03
  • 1
    Yeah, must have had a lot of issues. We started to use it on a project and ran in to problems. I agree it's probably one for the next project rather than retrofitting. – Ian Graham Oct 12 '16 at 14:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.