4

I'm having a weird issue where my Multilist with Search field is searching my custom index instead of the sitecore_master_index for items contained in the custom index. The multilist field source is defined as

StartSearchLocation=query:../..&Filter=+_templatename:Outcome Question

The multi-list with search field exists on items with different templates. The ones which are not in my custom index work as expected. Here is the search log being recorded:

39724 09:41:45 INFO Solr Query - ?q=((((((-_group:(29ebd112a0694e4bb80482374063e617) :) AND (-_group:(569c996fdf134dbca01a9dda4fc2c17b) :)) AND (-_group:(167e8210fc5440d9bfecf4b8bd51f75d) :)) AND ((_path:(26db877f40734a8a830b5397a3f11c36) AND _templatename:("Outcome Question")) AND _latestversion:(True))) AND _latestversion:(1)) AND _datasource:(sitecore))&start=0&rows=20&fl=*,score&fq=_indexname:(sitecore_master_index)

Here is the same field in the search log when using an item in my custom index

10408 09:41:49 INFO Solr Query - ?q=((((_path:(3493fb4172c24747a2bb5930cec674f8) AND _templatename:("Outcome Question")) AND _latestversion:(True)) AND _latestversion:(1)) AND _datasource:(sitecore))&start=0&rows=20&fl=*,score&fq=_indexname:(custom_things_master_index)

I don't want this to happen because my custom index doesn't have all the things that are in sitecore_master_index but I am not sure why/how this is happening. Here is the index definition

<index id="custom_things_master_index" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider" >
        <param desc="name">$(id)</param>
        <param desc="core">$(id)</param>
        <param desc="propertyStore" ref="contentSearch/indexConfigurations/databasePropertyStore" param1="$(id)" />
        <configuration ref="contentSearch/indexConfigurations/customthingsIndexIndexConfiguration" />
        <strategies hint="list:AddStrategy">
          <strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/syncMaster" />
        </strategies>
        <locations hint="list:AddCrawler">
          <crawler type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch">
            <Database>master</Database>
            <Root>/sitecore/content/site</Root>
          </crawler>
        </locations>
        <enableItemLanguageFallback>false</enableItemLanguageFallback>
        <enableFieldLanguageFallback>false</enableFieldLanguageFallback>
      </index>

Then the index configuration looks like this

<customthingsIndexIndexConfiguration ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration">
      <documentOptions ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration/documentOptions">            
        <include hint="list:AddIncludedTemplate">
          <templateType>{A59021E5-1A6D-449F-81FB-197CBD7770F4}</templateType>
          ...(more types)
        </include>
      </documentOptions>
    </customthingsIndexIndexConfiguration>

My next step is going to be decompiling/overriding pipelines until I can debug into this to see how the custom index is taking precedence over sitecore_master_index in this context. I'm hoping to avoid that if possible.

Any suggestions or things that seem out of whack here?

Edit: Attempt 1

I tried setting the index filter as part of the sourcing but no dice StartSearchLocation=query:../..&Filter=+_templatename:Outcome Question|+_indexname:sitecore_master_index and StartSearchLocation=query:../..&Filter=+_templatename:Outcome Question&Filter=+_indexname:sitecore_master_index

But those both attempted to add the index filter within the custom index

?q=(((((_path:(0eee5f32251547558f721d80e6a7a376) AND _templatename:("Outcome Question")) AND _indexname:(sitecore_master_index)) AND _latestversion:(True)) AND _latestversion:(1)) AND _datasource:(sitecore))&start=0&rows=20&fl=*,score&fq=_indexname:(custom_things_programs_master_index)

1
  • Can you change the name of your index to be "zcustom_things_programs_master_index" ? I think sitecore just grab the first index that includes your item alphabetically Commented Jan 26, 2018 at 16:09

1 Answer 1

3

Try filtering explicitly by the index you want to be searched: StartSearchLocation=query:../..&Filter=+_templatename:Outcome Question&Filter=+_indexname:sitecore_master_index

Edit 1

According to this blog post, https://community.sitecore.net/technical_blogs/b/sitecore_7_development_team/posts/using-the-new-sitecore-7-field-types, the StartSearchLocation is used to determine the index. If possible, you should try setting StartSearchLocation to {11111111-1111-1111-1111-111111111111} and try achieving your query via the Filter parameters, instead.

Edit 2

It appears that the code uses the value of StartSearchLocation to lookup the item in Sitecore. It then calls ContentSearchManager.GetIndex(item) to get the index. That code runs the contentSearch.getContextIndex pipeline where <processor type="Sitecore.ContentSearch.Pipelines.GetContextIndex.FetchIndex, Sitecore.ContentSearch"/> performs some logic to determine which index to use based on the item. Adding a processor to this pipeline or overriding FetchIndex may be the cleanest way to modify the results.

The FetchIndex class does some logic to rank the indexes to determine the best match. First it determines if the item is in the index. If it is in multiple indexes, the indexes whose RootItem is closest to the StartSearchLocation's item wins.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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