Wednesday 10 September 2014

SharePoint site column as search refiner


Steps:

Create a site column Ex: MyCustomColumn
Add site column in to a list
Now add data to list, now you are expecting your site column data should come in search refiner.

By default sharepoint will not add your site column as refiner, so we have to configure that.

Go to Site Settings --> click Search Schema under Site Collection Administration
Enter "RefinableString01"
From the Property Name menu, click Edit/Map Property.
Under Alias, enter some name...
On the Edit Managed Property page, click Add a Mapping.
In the Crawled property selection dialog box, use the Search for a crawled property name field to search for the crawled property that you want to map to this managed property.
My Site column is: MyCustomColumn
Enter MyCustomColumn and search.

Two crawled properties are found: ows_q_NMBR_MyCustomColumn and ows_MyCustomColumn.
but which one should we choose to map to the refinable managed property?

For all site column, one crawled property will create automatically..
Now we have to find which one is automatically created?
 ows_<something>_SiteColumnName   this format one is automatically created one.

I’ll call the other crawled property, ows_MyCustomColumn, a regular crawled property.

Now here’s the important part: When mapping a crawled property to a refinable managed property, you should select the regular crawled property!
Select the regular crawled property, and click OK. In our scenario, we’ll select ows_MyCustomColumn.
On the Edit Managed Property page, notice that the crawled property ows_MyCustomColumn has been added to the Mappings to crawled properties field.
Ok.
Now initiate a reindexing.
How to do it?
Go to list settings.
click on "Advanced Settings" link.
Under "Search",  you will find: Allow items from this list to appear in search results?
Select "Yes"
You will find "Reindex List"
Click "Reindex List".
After clicking on the button we will see a popup specifying without changing the document library items don't ReIndex the document library. Click on "Reindex Document Library" button to re crawl document library.
reindexing is done...

Now go to search page...

Open refiner web part
Edit webpart.
Click on Choose Refiners...
In the popup window, under "Available refiners", you can find for "RefinableString01"
Select "RefinableString01"
Click "Add"
Select "RefinableString01" from right list box
You will find: Display name
Enter some name...
Ok
Ok
Save
Wait for crawl...
Now in the search page, you will see "MyCustomColumn" column data from list as refiner....

If you are doing in cross site publishing, you have map refiners in authoring and publishing site. Other wise it will not work.

Cool right...:)