6

I recently upgraded from Sitecore v7.5 to v8.1. In addition my Solr configuration changed a little. On v7.5 I only had a single core. On v8.1 I now have many cores. After upgrading my search code is not returning any results and I am debugging it. I am wondering if maybe my code isn't searching the right Solr core. So I am wondering how the code knows which core to query.

Here is a code fragment for my search...

using (var context = ContentSearchManager.GetIndex("sitecore_web_index").CreateSearchContext()) {

   ... do search stuff
}

When I create the search context using that code am I telling the code to search through the core named "sitecore_web_index"? I guess it is unclear to me how the code knows which core to query.

9

The indexes are defined in configuration, and the core for that index is specified in that configuration section.

Here's the default 'sitecore_core_index' definition in an OOTB sitecore install (some properties elided for space):

<configuration type="Sitecore.ContentSearch.ContentSearchConfiguration, Sitecore.ContentSearch">
    <indexes hint="list:AddIndex">
      <index id="sitecore_core_index" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
        <param desc="name">$(id)</param>

        <param desc="core">$(id)</param>

      </index>
    </indexes>
  </configuration>

Notice the 'core' section, which uses the index id as its value. By default in later versions of sitecore, these indexes will map 1 to 1 with cores, so in this particular case, the 'sitecore_core_index' would be using a core named 'sitecore_core_index'.

You are free to change this value to anything you'd like - you just need to remember to create the requisite core in SOLR.

  • Ok thanks. That makes sense. So in my code when I am specifying the index name, it uses the config file to translate that and know which core to query. Thanks. – Corey Burnett Oct 14 '16 at 18:54
1

Core name is defined in index configuration:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <contentSearch>
      <configuration type="Sitecore.ContentSearch.ContentSearchConfiguration, Sitecore.ContentSearch">
        <indexes hint="list:AddIndex">
          <index id="MyIndex" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
            <param desc="name">$(id)</param>
            <param desc="core">MyCore</param>
            <param desc="propertyStore" ref="contentSearch/indexConfigurations/databasePropertyStore" param1="$(id)" />
            <configuration ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration" />
          </index>
        </indexes>
      </configuration>
    </contentSearch>
  </sitecore>
</configuration>

You can use $(id) value if core name and index names are the same.

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.