Introduction:
In this post we will see how we can create Sitcore solr index. Overall just to create index is simple and smooth process. All we need to do is add Folder in SOLR, add Core Index into SOLR, add custom index file into the Content Search folder (Ideally in Include Folder). Restart your app pool for the Sitecore instance. then go to control panel of sitecore. under indexing section select populate Solr managed schema followed by Indexing manager rebuilding the newly created Index. Let us see how it can be done with an example.
1- Create SOLR Custom Folder:
Create Folder in Solr As Shown Below. Ideally, Copy the existing Folder and Delete all the redundant Data. As shown below.
fig.1
the copied folder will have folders as shown below.
fig.2
Delete "core.properties", Delete everything within data folder.
2- Add Index mapping In SOLR:
Go to Solr Url. Usually it is https:// DomainName:8983/solr/#
In my case since I had installed solr in 8984 port my Url is bit different.
We will follow the steps mentioned below.
fig.3
3- Creating custom Index File.
let us say we have a requirement and now we are suppose to create an Index. so the very first step will be to have the Index ready. The easiest way will be to copy the existing , most similar index and modifying the same.
Usually, you will have a similar folder path as shown below.
"C:\inetpub\wwwroot\SC10sc.dev.local\App_Config\Sitecore\ContentSearch"
the one marked in Bold is the folder that is mapped to your Sitecore Application. the later part will be the same. All you will see there is config file that are indexed in Solr.
fig.4
Here you can see all the 3 web , master and core are mapped into Solr.
Now just to have a config file ready for custom indexing, we will copy and modify the existing index. in our scenario we will modify master config (Sitecore.ContentSearch.Index.Master.config).
fig.5
Now we update the above copied and renamed file as shown below.
In the above snap short, we can see the changes are made as per our custom index, Id name changed, core name changed, root path changed to where we want the index to work. (Note: the name here should be the same as you mentioned in SOLR while creating Index in Core figure 3, Number 3 and 4)
Here we have added the file into path "C:\inetpub\wwwroot\SC10sc.dev.local\App_Config\Sitecore\ContentSearch" which is not a great idea as this will become an issue during Upgradation or if we need to setup Sitecore again.
Once your initial index file is ready, move it to Include folder with proper Strategy, in our scenario we have created Folder naming ZZ -> Custom Index.
4- Restart Sitecore App Pool:
Now in order to check if this Index is available in our Sitecore instance we will have to recycle the app pool of our Instance.
check showconfig.aspx, since you have added your Index in ZZ folder, you will see custom index is the last patch.
Now if you check your Sitecore instance , go to Control panel and click on populate solr managed schema, still your Index will not show up. Try stop and start on app pool still index will not show up. I think it should have shown up and the we would have used "Populate SOLR Managed Schema" from control panel to make it available into SOLR.
5- Populate SOLR Index:
I did wait for Sitecore to start over and ask for Login. I was now able to see the Custom Index.
fig.9
click "Populate Solr Managed Schema", unselect all the Indexes and only Select our Custom Index, Click Populate.
6- Rebuild Index:
Now under control panel, select Indexing manager. Again unselect all of the indexes, select only newly created custom index. rebuild.
Conclusion:
As first step we have successfully created and synced Index with SOLR. Since my Index was not showing up after creation in Sitecore I had to manually create one in SOLR and sync both. once we have the base ready we can now try to put the field and info we want to be part of Index. We will see it in another post
Comments
Post a Comment