How do I rebuild a custom Lucene index on a Sitecore content delivery server?
Asked Answered
F

5

6

The custom Lucene index on my Sitecore 6.2 Content Delivery server seems to be not right. So I think I need to rebuild all 3 of my custom indexes. How do I do that? Do I just have to use the shared source Index Viewer module? Right now I have that installed on my CD server, however for some reason it is not working. When I select my custom index in Index Viewer - nothing happens. So I can't rebuild the index that way. Can I just delete the index files from the hard drive? If so, how quickly will Lucene rebuild them?

Feet answered 30/9, 2013 at 18:50 Comment(1)
Currently the Index Viewer does not have the ability to rebuild indexes remotely (ie from CM on CD). However I am working on a version where it is possible.Carpo
F
3

I ended up contacting Sitecore support and they pointed me to the shared source module called Sitecore Support Toolbox - http://marketplace.sitecore.net/en/Modules/Sitecore_Support_Toolbox.aspx. Once I installed that I was able to easily rebuild my indexes.

Feet answered 3/10, 2013 at 12:40 Comment(1)
Anyone know where the Sitecore Support Toolbox went? It's no longer available on Marketplace.Perfidy
D
3

As noted above, earlier versions of Sitecore 6.x required custom indexes to be rebuild using either IndexViewer or with some custom code. I believe in a revision of 6.5 the Control Panel > Database > Rebuild Search Indexes began including custom indexes so IndexViewer is no longer necessary (but should still work).

To your specific question though, on my CD servers I have a rebuild script that can be called directly to rebuild search indexes. I forget where I found this script (believe it was something published by Alex Shyba at Sitecore). You can find the details of this script at https://gist.github.com/Refactored/6776801

However, I believe you have a different issue that needs to be addressed. If your CD servers aren't detecting changes and therefore not updating you have a configuration issue. I would start with this article when troubleshooting index issues: http://sitecoreblog.alexshyba.com/2011/04/search-index-troubleshooting.html

Diego answered 1/10, 2013 at 10:58 Comment(0)
F
3

I ended up contacting Sitecore support and they pointed me to the shared source module called Sitecore Support Toolbox - http://marketplace.sitecore.net/en/Modules/Sitecore_Support_Toolbox.aspx. Once I installed that I was able to easily rebuild my indexes.

Feet answered 3/10, 2013 at 12:40 Comment(1)
Anyone know where the Sitecore Support Toolbox went? It's no longer available on Marketplace.Perfidy
L
2

Since Sitecore 6.6 update 3 or 4 (don't remember which one was it) you can rebuild your custom indexes from the Sitecore Control Panel.

In all previous versions you need to rebuild it from code or using custom modules for Sitecore. Deleting index files won't work.

The simplest code for rebuilding custom Sitecore Lucene Index is:

Sitecore.Search.SearchManager.GetIndex("your_index_name").Rebuild()

The blog post "Troubleshooting Sitecore Lucene search and indexing" can help you if rebuilding the index won't solve your problem.

Lummox answered 30/9, 2013 at 19:52 Comment(0)
F
1

I have come across the same requirement in one of my projects. Here was my solution:

  1. Create a configuration content item with a template that has only one field, say "Rebuild Index", default value is "1", example of the item path could be: "/sitecore/content/mysite/config/index rebuild flag"
  2. Create an IndexRebuilder class that has a Run method. Within the Run method, check the "index rebuild flag" item (from the Context database) and rebuild the index on the server if the "Rebuild Index" field value equals to "1". After rebuilt successfully, update the item field value to "0".
  3. Set up, a scheduled agent that points to the IndexRebuilder class. For examples,

    <agent type="MyAssembly.IndexRebuilder, MyAssembly" method="Run" interval="00:00:00"/>

    Notice that the interval is "00:00:00" by default, to turn off the agent on content management server. Your build and deployment process should turn this value to say "00:05:00", which allow the agent to run on every 5 minutes.

From there, to rebuild index on content delivery server, just publish the "index rebuild flag" item from master database to the content delivery database (web) and the index on your content delivery server should start rebuilding in 5 minutes.

Furnary answered 3/10, 2013 at 4:46 Comment(0)
A
0

Clicking Index Viewer with nothing happening, is usually an indication of certain files of the Index Viewer package having not been deployed to your CD server. Easiest fix for this - if you do have /sitecore running on the CD server - is to just re-install the package directly on the CD server. After this, IndexViewer will work.

If you don't have a /sitecore on your CD server (Sitecore recommends removing this, or at least blocking access to it) - it becomes more problematic. I would recommend setting a page/webservice or similar, executing the code Maras suggests above - that way you can always trigger an index rebuild when you need it.

Amplification answered 1/10, 2013 at 8:14 Comment(2)
There is a rebuild index script in the support toolbox. This could be selectively deployed: marketplace.sitecore.net/en/Modules/…Loveinidleness
Nice. Hadn't seen that one before :-)Amplification

© 2022 - 2024 — McMap. All rights reserved.