3

I'm using Sitecore 8.0 update 5. I'm a having a strange issue with Lucene.

I'm trying to update a product in the index with the following code:

var tempItem = (SitecoreIndexableItem)item;  

ContentSearchManager.GetIndex("sitecore_products_index").Refresh(tempItem);

Instead of an update, the code creates a new product entry in the index with no data (blank). If I debug, I can see the uniqueid is matching, so I'm not sure what is causing this behavior. If I simply do a '.Rebuild()', it refreshes the index with the new product, but I don't want to do that for one product change.

In addition to this, OnPublishEndAsync wasn't working either. Products change and the index won't refresh.

I found this bug fix, but it didn't seem to work for me: https://kb.sitecore.net/articles/992608

Thanks for any help!

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
   <sitecore>
    <contentSearch>
      <configuration type="Sitecore.ContentSearch.ContentSearchConfiguration, Sitecore.ContentSearch">
        <indexes hint="list:AddIndex">
          <index id="sitecore_products_index" type="Sitecore.ContentSearch.LuceneProvider.LuceneIndex, Sitecore.ContentSearch.LuceneProvider">
            <param desc="name">$(id)</param>
            <param desc="folder">$(id)</param>

            <!-- This initializes index property store. Id has to be set to the index id -->
            <param desc="propertyStore" ref="contentSearch/indexConfigurations/databasePropertyStore" param1="$(id)" />

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

            <indexAllFields>true</indexAllFields>

            <fields hint="raw:AddComputedIndexField">
                    <field fieldName="Back Image" storageType="YES" indexType="TOKENIZED">Service.Lucene.ImageIndexField, Service</field>
                    <field fieldName="Front Image" storageType="YES" indexType="TOKENIZED">Service.Lucene.ImageIndexField, Service</field>
                    <field fieldName="ExternalID" storageType="YES" indexType="TOKENIZED">Service.Lucene.TextIndexFieldAddOn, Service</field>
                    <field fieldName="Brand" storageType="YES" indexType="TOKENIZED">Service.Lucene.TextIndexFieldAddOn, Service</field>
                    <field fieldName="Region" storageType="YES" indexType="TOKENIZED">Service.Lucene.TextIndexFieldAddOn, Service</field>
                    <field fieldName="Substrates" storageType="YES" indexType="TOKENIZED">Service.Lucene.TextIndexFieldAddOn, Service</field>
                    <field fieldName="Categories" storageType="YES" indexType="TOKENIZED">Service.Lucene.TreeListexIndexFieldAddOn, Service</field>
                    <field fieldName="Certification Icons" storageType="YES" indexType="TOKENIZED" patch:after="field[last()]">Service.Lucene.TreeListexIndexField, Service</field>
                    <field fieldName="Applications" storageType="YES" indexType="TOKENIZED" patch:after="field[last()]">Service.Lucene.TreeListexIndexField, Service</field>
            </fields>

            <fieldMap type="Sitecore.ContentSearch.FieldMap, Sitecore.ContentSearch">
                <fieldNames hint="raw:AddFieldByFieldName">
                  <field fieldName="Page Title" storageType="YES" indexType="TOKENIZED" vectorType="YES" boost="1f" type="System.String"
                       settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider" />
                <field fieldName="Product Number" storageType="YES" indexType="TOKENIZED" vectorType="YES" boost="1f" type="System.String"
                       settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider" />
                       <field fieldName="Short Description" storageType="YES" indexType="TOKENIZED" vectorType="YES" boost="1f" type="System.String"
                       settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider" />
                       <field fieldName="Full Description" storageType="YES" indexType="TOKENIZED" vectorType="YES" boost="1f" type="System.String"
                       settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider" />
                       <field fieldName="Features Description" storageType="YES" indexType="TOKENIZED" vectorType="YES" boost="1f" type="System.String"
                       settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider" />
                       <field fieldName="Patent Numbers" storageType="YES" indexType="TOKENIZED" vectorType="YES" boost="1f" type="System.String"
                       settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider" />
                       <field fieldName="Discontinued" storageType="YES" indexType="TOKENIZED" vectorType="YES" boost="1f" type="System.String"
                       settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider" />
                       <field fieldName="_uniqueid" storageType="YES" indexType="TOKENIZED" vectorType="YES" boost="1f" type="System.String"
                       settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider" />
                </fieldNames>

              </fieldMap>
              </configuration>

            <strategies hint="list:AddStrategy">
              <!-- NOTE: order of these is controls the execution order -->
              <strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/onPublishEndAsync" />
            </strategies>
            <commitPolicyExecutor type="Sitecore.ContentSearch.CommitPolicyExecutor, Sitecore.ContentSearch">
              <policies hint="list:AddCommitPolicy">
                <policy type="Sitecore.ContentSearch.TimeIntervalCommitPolicy, Sitecore.ContentSearch" />
              </policies>
            </commitPolicyExecutor>

            <locations hint="list:AddCrawler">
              <crawler type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch">
                <Database>master</Database>
                <Root>/sitecore/content/Products</Root>
              </crawler>
            </locations>

          </index>
        </indexes>
      </configuration>
    </contentSearch>
  </sitecore>
</configuration>
3

2 Answers 2

2

For updating the index for a specific item, you can use the IndexCustodian

var toIndex = ContentSearchManager.GetIndex("sitecore_products_index");

if(toIndex != null)
{
    var tempItem = (SitecoreIndexableItem)item;
    IndexCustodian.Refresh(toIndex,tempItem);
}

The index custodian will start a job for updating your index.

3
  • Unfortunately, no luck with this one. Commented Jun 6, 2017 at 11:52
  • Can you verify if any job is starting in the jobs.aspx page? link is yourhostname/sitecore/admin/jobs.aspx
    – adarsh
    Commented Jun 6, 2017 at 12:30
  • Nothing is running in jobs. When I update a product, I can see the index job fire off and finish. Commented Jun 6, 2017 at 12:44
0

We are going to upgrade soon, so hopefully this will resolve that issue. In the meantime, I updated this to .Rebuild() with an optimized configuration file. The index process is extremely quick. Thanks for the suggestions.

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.