0

Using Sitecore v8.0 Update-5

I'm working on Sitecore search for the first time. This is for a website search where the end user/visitor will search for pages/content on site using keywords.

Following this article, I created a custom index. When executing the code which performs the search, it throws the following error:

'contentSearch/indexConfigurations/databasePropertyStore' has an invalid token

var indexName = "mysite_master_search_index";
using (var context = ContentSearchManager.GetIndex(indexName).CreateSearchContext()) //ERROR HERE
{
 .... 
}

Except for the database names and adding the default computed field _content, I did not make any changes in this config.

Filename: MySite.ContentSearch.Lucene.config

Path: /App_Config/Include/MySite/

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <contentSearch>
      <configuration type="Sitecore.ContentSearch.ContentSearchConfiguration, Sitecore.ContentSearch">
        <indexes hint="list:AddIndex">
          <index id="mysite_master_search_index" type="Sitecore.ContentSearch.LuceneProvider.LuceneIndex, Sitecore.ContentSearch.LuceneProvider">
            <param desc="name">$(id)</param>
            <param desc="folder">$(id)</param>
            <param desc="propertyStore" ref="contentSearch/indexConfigurations/databasePropertyStore" param1="$(id)" />
            <configuration ref="contentSearch/indexConfigurations/mysiteSearchConfiguration" />
            <strategies hint="list:AddStrategy">                  
              <strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/syncMaster" />              
            </strategies>
            <commitPolicyExecutor 
             ....
            </commitPolicyExecutor>
            <locations hint="list:AddCrawler">
              <crawler type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch">                    
                <Database>master</Database>                
                <Root>/sitecore/content/Home/MySite/Home</Root>
              </crawler>
            </locations>
          </index>
          </indexes>
      </configuration>
      <indexConfigurations>
        <mysiteSearchConfiguration type="Sitecore.ContentSearch.LuceneProvider.LuceneIndexConfiguration, Sitecore.ContentSearch.LuceneProvider">
          <indexAllFields>false</indexAllFields>
          <initializeOnAdd>true</initializeOnAdd>
          <analyzer ref="contentSearch/indexConfigurations/defaultLuceneIndexConfiguration/analyzer" />
          <fieldMap type="Sitecore.ContentSearch.FieldMap, Sitecore.ContentSearch">
            <fieldNames hint="raw:AddFieldByFieldName">
              <field fieldName="_uniqueid" storageType="YES" indexType="TOKENIZED" vectorType="NO" boost="1f" type="System.String" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider">
                <analyzer type="Sitecore.ContentSearch.LuceneProvider.Analyzers.LowerCaseKeywordAnalyzer, Sitecore.ContentSearch.LuceneProvider" />
              </field>
            </fieldNames>
          </fieldMap>
          <fields hint="raw:AddComputedIndexField">
            <field fieldName="_content" type="Sitecore.ContentSearch.ComputedFields.MediaItemContentExtractor,Sitecore.ContentSearch">
              <mediaIndexing ref="contentSearch/indexConfigurations/defaultLuceneIndexConfiguration/mediaIndexing"/>
            </field>
          </fields>
          <fieldReaders ref="contentSearch/indexConfigurations/defaultLuceneIndexConfiguration/fieldReaders"/>
          <indexFieldStorageValueFormatter ref="contentSearch/indexConfigurations/defaultLuceneIndexConfiguration/indexFieldStorageValueFormatter"/>
          <indexDocumentPropertyMapper ref="contentSearch/indexConfigurations/defaultLuceneIndexConfiguration/indexDocumentPropertyMapper"/>
        </mysiteSearchConfiguration>
      </indexConfigurations>
    </contentSearch>
  </sitecore>
</configuration>

So, in the content under, under the "Developer" tab, I tried all the options for building indexes in the "indexing tools" section, which shows a pop up dialog for error:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of 
an invocation. ---> 
System.InvalidOperationException: Could not find configuration node: contentSearch/databasePropertyStore at  
Sitecore.Configuration.Factory.GetConfigNode(String xpath, Boolean assert) 
at Sitecore.Configuration.Factory.CreateObject(String configPath, String[] 
parameters, Boolean assert) at.....

Did I miss any setting or is it not the way we should add a custom index.

UPDATE:

In developer tab, when I click on "Rebuild index" dropdown, there is this message - Indexes Gallery failed to render index list.

  • 1
    Looking at the index config you pasted above, you have closed the <indexes> tag just before defining <index id="mysite_search_index_web" – Marek Musielak Apr 3 '17 at 9:09
  • As 'Marek' mentioned , please check index tags are opened & closened. If they are fine, then you have to make sure 'databasePropertyStore' config is patched-up through Sitecore.ContentSearch.<Lucene/Solr>.Indexes.config – Balaji Kuppuswamy Apr 3 '17 at 9:24
  • Sorry that was a typo in question. The tags are correctly closed. – Qwerty Apr 3 '17 at 10:13
  • If they are fine, then you have to make sure 'databasePropertyStore' config is patched-up through Sitecore.ContentSearch.<Lucene/Solr>.Indexes.config – Balaji Kuppuswamy Apr 3 '17 at 10:14
  • @BalajiKuppuswamy How do I make sure 'databasePropertyStore' config is patched-up. Could you please explain. – Qwerty Apr 3 '17 at 10:16
3

ANALYSIS

The error

'contentSearch/indexConfigurations/databasePropertyStore' has an invalid token

shows that the XPath contentSearch/indexConfigurations/databasePropertyStore has an invalid token.

The reason is because you have copy and paste the config file from the mention article. The databasePropertyStore has invalid characters due to encoding.

From notepad++, when I have double clicked on the word databasePropertyStore, only one got selected, even if you see that they are the same as shown below:

Same encoding:

enter image description here

while with different encoding:

enter image description here

This shows that the word databasePropertyStore is different. Also, when changing encoding to ANSI, you clearly see the difference in the words:

enter image description here

This is why you are getting the above error as it is searching for this XPath: contentSearch/indexConfigurations/databasePropertyStore‌​

SOLUTION

You need to type in instead of copy paste. This will fix the issue.

2

In your configs I found that you are doing this <configuration ref="contentSearch/indexConfigurations/mysiteSearchConfiguration" /> in your indexes. Please make sure that in mysiteSearchConfiguration you are referencing Sitecore Default Lucene Index like this.

<mysiteSearchConfiguration ref="contentSearch/indexConfigurations/defaultLuceneIndexConfiguration">

Please note that this is a comment. I cannot comment due to insufficient points.

  • Added reference as you said, but no luck. It's still the same error. – Qwerty Apr 3 '17 at 10:58
  • @Qwerty In the index, you have defined the parameter propertyStore as <param desc="propertyStore" ref="contentSearch/databasePropertyStore" param1="$(id)" /> try this instead <param desc="propertyStore" ref="contentSearch/indexConfigurations/databasePropertyStore" param1="$(id)" /> – adarsh Apr 3 '17 at 11:59
  • That did not work too. Please see my Update in the question, if it helps. – Qwerty Apr 3 '17 at 12:42
  • To find which index in failing to render, have a different config file for each index. That is one called mySiteSearchMasterIndex.config for the master and the other for the web. Add one index at a time to know which is not correct. Maybe the xml is not build correctly. – adarsh Apr 3 '17 at 13:13
1

Some of your configuration elements are off, at least for Sitecore 8.

As mentioned by adarsh, you were missing the indexConfigurations/ subpath here:

<param desc="propertyStore" ref="contentSearch/indexConfigurations/databasePropertyStore" param1="$(id)" />

It's also missing from here:

<strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/syncMaster"/>

And here:

<strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/onPublishEndAsync" />

You can check showconfig.aspx and compare your index against stock indexes to make sure you are not missing anything else.

  • I have kept only one index now (for master) and updated the attributes as you have suggested. But still, in the developer tab, it says "Indexes Gallery failed to render index list." – Qwerty Apr 3 '17 at 13:57
  • Also, the error now in code is - 'contentSearch/indexConfigurations/databasePropertyStore‌​' has an invalid token – Qwerty Apr 3 '17 at 13:58
  • @Qwerty that error is strange. Are you sure you don't have a white space or some invisible character inside your ref property? Make sure you check in showconfig.aspx that your configuration is as expected. – maz Apr 3 '17 at 17:18
  • There are no spaces or such chars. When I see showconfig.aspx, could you please tell me what is "expected" – Qwerty Apr 4 '17 at 5:00
  • 1
    @Qwerty Expected in this case is making sure that your config patch is fully taken into account by Sitecore and appears as you would expect it to with no additional, unexpected characters. See Hishaam's answer for an example of surprises you might find. – maz Apr 4 '17 at 18:30

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.