Thursday, December 17, 2015

When do we need sharepoint full crawl?

Most of the developers have encountered this question, when exactly do we need to run the sharepoint full crawl? Why does incremental crawl is not enough.

Here are the following scenarios where full crawl is mandatory.

a) Search  service application created  in the farm and configured with content source(Its obvious)
b) New content source added/created.
c) Adding new  managed property/ updating the existing managed property.
d) After CRUD operation of Crawl Rules
d) If  search index  throwing errors
e) The  credentials of  user account that is assigned to the default content access account have changed
f)  Sharepoint Service pack installed

Atleast for  the above scenarios its  mandatory to run  the full crawl else  search does not return the required results :(




Monday, October 19, 2015

How to create and import thesaurus in SharePoint Server

Before deep dive into how to create and import first we will discuss about thesaurus

What is Thesaurus?

Its same as synonym or as per google :) "a book that lists words in groups of synonyms and related concepts"

Before jump into the details, we will make clear that it will be used in sharepoint search.

Why it is  important in sharepoint world?

As explained above this is used in sharepoint search, so many people can search for the same data using different key world.

ex: If user wants to search for Laptop, then the user can try with different keywords like shown below :

Lap top
Laptop
Laptops
Lappy
Lap-top

In all of the above cases its referring to Laptop only, but how our sharepoint will understand these keys will be explained in the post

The situation becomes even difficult when people use acronyms :(

ex: HD TV
Hi Definition TV etc

In all of the above cases, search doesn't return any of the record even when user is referring to the same type/record

How to overcome this issue?

In Sharepoint 2013 we can easily create and upload the thesaurus(csv format) that contains synonyms for search phrases and acronym as well.

How to create it?

First we need to identify which are thesaurus we need to use in the system like as explained for Laptop example

1) Then open notepad(We can use CSV also)

2)  In the notepad enter the columns name like Key,Synonym,Language
Note: It should be at the top and there is no  space between 3 words and it should be separated  by comma.
ex:Key,Synonym,Language









3) In the text editor add new line and enter a term or a phrase, a synonym for that term or phrase and a two letter language code. Use commas to separate the phrases, for example Lap-top,Laptop,en

Note: Here Language is optional 

Repeat the same steps for entering multiple term as like below

Lap top,Laptop,en
Laptop,Laptop,en
Laptops,Laptop,en
Lappy,Laptop,en
Lap-top,Laptop,en
Lap Top,Laptop,en
Lap Tops,Laptop,en

Save the file as .csv with UTF-8 encoding.

Now our thesaurus are ready for importing into Sharepoint.









How to import into sharepoint environment?

1) Open a SharePoint 2013 Management Shell with Admin account(Search service application administrator)

2) In the command prompt  enter  the  following command

$searchApp = Get-SPEnterpriseSearchServiceApplication 
Import-SPEnterpriseSearchThesaurus -SearchApplication $searchApp -Filename \\sharepoint2013\\D$\Searchthesaurus\Thesaurus.csv

Here file path is given in the UNC format. This commandlet expects the file path in this format.






Now our thesaurus are part of search, even if the user search for any of the term search will return the proper results

Things to consider:

When we import  the thesaurus  existing  thesaurus will be overwritten.

There is no export functionality to take backup of the  existing thesaurus
(Its good to maintain the thesaurus files in external system where we can update the new thesaurus)

After  importing  thesaurus it will reflect  immediately, there is no delay in reflection

Its always better to update the existing copy of the thesaurus file so that all old entries will be available.

Issue might encounter  and steps to fix the issue

1) If we run the commandlet without admin access it might throw exception

2) Search needs to be properly configured

3) Make sure whatever term you are mapping its coming in the search result or not before running the scripts
ex: Laptop word  is coming or not please verify before running this.

4) After running the commandlet if you are seeing the below error in ULS then we need to restart Search and Timer service
Failed to start the flow: Microsoft.ThesaurusDeployment. Exception: System.ServiceModel.FaultException: Cannot start flow. The admin service is unavailable.

5) Make sure Primary host controller is enabled in the front end server where this scripts is running