Search This Blog

Showing posts with label Sharepoint Search. Show all posts
Showing posts with label Sharepoint Search. Show all posts

Monday, March 14, 2016

SharePoint 2013 Query Suggestions

Query suggestions are phrases that you want the search system to suggest to users as they start typing a query. For example, as you start to type "Chicago", they may be able to pick  a word that starts with "Chicago" from a list below the Search Box.

The Query Suggestion feature needs to be enabled at the Service Application level to be activated.Once this is done there are 2 ways to implement query suggestion.

1. Manually upload the query suggestion list into SharePoint.

2. The search system automatically creates suggestions for a query when users have clicked one or more of the results for that query at least six times.

Manually uploading the query suggestion

1. Browse to Central Administration -> Service Applications -> Search Service Application.

2. Go to Queries and Results -> Query Suggestions


3. Select Show Query Suggestions

4. In Always suggest phrases -> Import from text file


5. Browse to Central Administration -> Monitoring -> Review job definitions ->Prepare query suggestions -> Run Now

6. In this example, I start typing for the word �Chicago, all words starting with Chicago is automatically picked up.



Implementing Thesaurus in SharePoint 2013

1. Create a thesaurus file
2. Deploy/Import the Thesaurus file
3. Check the results

1. Create a thesaurus file

- In the Keycolumn, enter the term (single or multiple words) that you want to trigger a synonym for when the term occurs in a query.
- In the Synonymcolumn, enter the synonym (single or multiple words) that you want to add to the query if the term specified in the Key column occurs in a query.
- In the optional Languagecolumn, enter the abbreviation for the language for which the synonym should apply.
Example of a thesaurus looks like this:
 Key,Synonym,Language
IE,Internet Explorer
Internet Explorer,IE
UN,United Nations,en
UN,Vereinte Nationen,de

2. Deploy/Import the Thesaurus file

Start the SharePoint 2013 Management Shell.
$searchApp = Get-SPEnterpriseSearchServiceApplication
Import-SPEnterpriseSearchThesaurus -SearchApplication $searchApp -Filename <Path>

<Path> specifies the full UNC path of the .csv file (the thesaurus) to be imported.Universal Naming Convention (UNC) is a way to identify a shared file in a computer without having to specify (or know) the storage device it is on. 

In Windows operating systems, the UNC name format is:

3. Check the results

When you search for "IE" you should get results with "IE" and "Internet Explorer"

SharePoint 2013 Thesaurus or Synonyms

SharePoint 2013 Thesaurus or Synonyms

The Thesaurus feature in SharePoint is associated with the SharePoint Search Service Application. In SharePoint Search if you want to include synonyms also in Search results for specific keywords, you need to import a thesaurus file into SharePoint.

In case you search for IE and you want the Search Results to include IE and Internet explorer, you need to have a thesaurus file uploaded with these entries into SharePoint

Thesaurus file is normally used to specify synonyms for a single word or multiple words that occur in queries. The query is expanded based on the entries in the thesaurus. You create and maintain the thesaurus file in a system external to SharePoint 2013 before you import it into SharePoint 2013 to make the synonyms available to the search system.
It should be a .csv file with the columns Key, Synonym and Language

- In the Keycolumn, enter the term (single or multiple words) that you want to trigger a synonym for when the term occurs in a query.

- In the Synonymcolumn, enter the synonym (single or multiple words) that you want to add to the query if the term specified in the Key column occurs in a query. Synonyms consisting of multiple words will be added as phrases to the query.

- In the optional Languagecolumn, enter the abbreviation for the language for which the synonym should apply.If you leave this column empty, the query is expanded with the synonym regardless of the query language.
Note : Make sure there are no leading or trailing spaces around the terms

Example of a thesaurus looks like this :
Key,Synonym,Language
IE,Internet Explorer
Internet Explorer,IE
UN,United Nations,en
Implementing Thesaurus in SharePoint 2013

Thursday, March 3, 2016

PowerShell to get the details of Content Sources in the SharePoint Search Service Application

This example retrieves the default content source for the search service application.

$ssa = Get-SPEnterpriseSearchServiceApplication

Get-SPEnterpriseSearchCrawlContentSource -SearchApplication $ssa


Name                           Id    Type                CrawlState CrawlCompleted     
----                               --      ----                   ---------- --------------     
Local SharePoint sites     1     SharePoint           Idle                          
Content Source 1           17    SharePoint           Idle       2/2/2016 2:58:46 PM
Content Source 2            6     SharePoint           Idle       2/2/2016 1:57:00 PM
Content Source 3            12   SharePoint           Idle       2/2/2016 11:57:40 AM
Content Source 4            14   SharePoint           Idle       2/2/2016 11:58:14 AM
Content Source 5            15   SharePoint           Idle       2/2/2016 3:27:58 PM



Wednesday, February 17, 2016

SharePoint 2013 Crawl job will not stop

When you are unable to stop a crawl (full or incremental) using the Central Administration UI, you can try one of the below steps

Approach 1 (Restart Search services)

1. Stop and start the SharePoint Server Search 15 service
2. Go to services.msc -> SharePoint Server Search 15 -> Restart
Run the PowerShell script on the SharePoint server

Approach 2 (Using net start command)

net stop OSearch15
net start OSearch15

Approach 3 (Using PowerShell command)

Stop-Service -name OSearch15
Start-Service -name OSearch15

Approach 4 (PowerShell script to stop the SharePoint Crawl Job)

Add-PSSnapin "Microsoft.SharePoint.PowerShell"
Get-SPEnterpriseSearchCrawlContentSource -SearchApplication "Search Service Application" | ForEach-Object {
     if ($_.CrawlStatus -ne "Idle")
     {
         Write-Host "Stopping currently running crawl for content source $($_.Name)..."
         $_.StopCrawl()
       
         do { Start-Sleep -Seconds 1 }
         while ($_.CrawlStatus -ne "Idle")
     }
}

Approach 5 (Perform an Index rest)

Browse to Central Administration -> Search Service Application -> Crawling-> Index Reset -> Reset Now
Note: Resetting the crawled content will erase the content index. After a reset, search results will not be available until crawls have been run.

Tuesday, April 28, 2015

Internal server error exception: System.NullReferenceException: Object reference not set to an instance of an object

Error Description

Recently I came across this error with SharePoint Search. I was searching in a SharePoint list and got the below error.
Error
Internal server error exception:
Troubleshoot issues with Microsoft SharePoint Foundation.

On checking the ULS logs I found the below entries

01/28/2015 10:59:51.10         w3wp.exe (0x31D8)                0x2030    SharePoint Server Search      Query      fm9a        Unexpected                CoreResultsWebPart::OnInit: Exception initializing: System.NullReferenceException: Object reference not set to an instance of an object.     at Microsoft.Office.Server.Search.WebControls.CoreResultsWebPart.SetPropertiesOnQueryReader()     at Microsoft.Office.Server.Search.WebControls.CoreResultsWebPart.OnInit(EventArgs e)               7001a8bf-b506-4096-b46b-003fbb5ec91b

01/28/2015 10:59:51.10         w3wp.exe (0x31D8)                0x2030    SharePoint Server Search      Query      g1j9         Exception                Internal server error exception: System.NullReferenceException: Object reference not set to an instance of an object.     at Microsoft.Office.Server.Search.WebControls.CoreResultsWebPart.SetPropertiesOnQueryReader()     at Microsoft.Office.Server.Search.WebControls.CoreResultsWebPart.OnInit(EventArgs e) System.NullReferenceException: Object reference not set to an instance of an object.     at Microsoft.Office.Server.Search.WebControls.CoreResultsWebPart.SetPropertiesOnQueryReader()     at Microsoft.Office.Server.Search.WebControls.CoreResultsWebPart.OnInit(EventArgs e)               7001a8bf-b506-4096-b46b-003fbb5ec91b


01/28/2015 10:59:51.10         w3wp.exe (0x31D8)                0x2030    SharePoint Server  Unified Logging Service       c91s        Monitorable                Watson bucket parameters: SharePoint Server 2010, ULSException14, 06175311 "sharepoint server search", 0e001b67 "14.0.7015.0", 17853a8f "microsoft.office.server.search", 0e001bd1 "14.0.7121.0", 531f1826 "tue mar 11 10:05:26 2014", 000032a4 "000032a4", 0000002d "0000002d", 4a6d3421 "nullreferenceexception", 67316a39 "g1j9"    7001a8bf-b506-4096-b46b-003fbb5ec91b


Solution 1

If you go into Central Administration -> System Settings -> Manage Services on Server. Make sure the below services are started.

- SharePoint Server Search
- Search Query and Site Settings Service

Solution 2

Click through all the Search Administration pages in Central Admin.Click through all the Search Administration pages in Central Admin. Now perform the search again. The issue should have disappeared.


Solution 3

Identify the underlying application pool for search (Reference)
Perform an application pool recycle

Wednesday, April 15, 2015

SharePoint Crawled Properties and Managed Properties

Last year, when I had an interview, I was asked the difference between crawled property and managed property. Though I have come across this multiple times and even after working on Search Project, I could not give a satisfactory answer.(honestly ,even for me the answer was not satisfactory)

So what is CrawledProperty and Managed Property in SharePoint ???

Crawled Properties and Managed Properties are very basic SharePoint concepts but they are building elements of SharePoint Search. Below is an example which might help you understand this in a better way.
SharePoint crawls data from different sources. The data in these various source systems have metadata which can have different names but it refers to the same information.

As an example different systems can store the information about the Author in various systems with the name as :

Author
Created By
Writer
Owner
and in case of emails it is stored in field From.

But all these fields represent the same information which represent who has created this.

Now when SharePoint crawl these various systems , all these properties become Crawled Properties.
In SharePoint we can group all these Crawled Properties under one Managed Properties.
The below image is a pictorial representation of what I said above.


















Note

One crawled property can be part of multiple Managed Properties.
Managed property can be used in scopes, refiners..etc.

Friday, April 10, 2015

SharePoint Search Service Application Creation through PowerShell

Search service Application can be created and configured through Central Administration and PowerShell as well. The below commands creates the Search Service Application and the associated databases.Further configuration can be done from Central Administration. The main purpose of doing this is to create search related databases without GUID�s.

$SSADB = "SearchDB�
$SSAName = "Search Service Application"
$SVCAcct = "Domain\UserName"
$SSI = Get-SPEnterpriseSearchServiceInstance -local

1. Start Services search services for SSI
Start-SPEnterpriseSearchServiceInstance -Identity $SSI

2. Create an Application Pool.
$AppPool = New-SPServiceApplicationPool -Name $SSAName" AppPool" -account $SVCAcct

3. Create the SearchApplication and set it to a variable
$SearchApp = New-SPEnterpriseSearchServiceApplication -Name $SSAName -Applicationpool $AppPool -DatabaseName $SSADB

4. Create search service application proxy
$SSAProxy = New-SPEnterpriseSearchServiceApplicationProxy -Name $SSAName" ApplicationProxy" -Uri $SearchApp.Uri.AbsoluteURI

5. Provision Search Admin Component.
Set-SPEnterpriseSearchAdministrationComponent -SearchApplication $SearchApp -SearchServiceInstance $SSI

The database names would be as below by running the above PowerShell.

Administration Database: SearchDB
Crawl Database: SearchDB_CrawlStore
Property Database: SearchDB_PropertyStore

Wednesday, February 4, 2015

Error - �The given key was not present in the dictionary."

PowerShell command to delete the query suggestion automatically added by SharePoint(suggestions are automatically built based on what search results are actually clicked on. It takes 6 clicks within a year for SharePoint to add a suggestion)), returns an error

Remove-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication "SharePoint Server Search" -Language En-Us -Type QuerySuggestionAlwaysSuggest -Identity "ford"

Remove-SPEnterpriseSearchLanguageResourcePhrase : The given key was not present in the dictionary.
At line:1 char:48 + Remove-SPEnterpriseSearchLanguageResourcePhrase <<<<  -SearchApplication "SharePoint Server Search" -Language En-Us -Type QuerySuggestionAlwaysSuggest -Identity ford
    + CategoryInfo          : InvalidData: (Microsoft.Offic...eResourcePhrase:   RemoveSearchLanguageResourcePhrase) [Remove-SPEnterp...eResourcePhrase], KeyNotFoundException
    + FullyQualifiedErrorId : Microsoft.Office.Server.Search.Cmdlet.RemoveSearchLanguageResourcePhrase



I could not find a way to remove a query suggestion added by SharePoint. Maybe it is a bug. But we do have an option to block them. This way we can stop them from appearing on the search box.

To block the query suggestion "ford"

New-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $SearchApp -Language en-us -Type QuerySuggestionBlockList -Name �ford�
Start-SPTimerJob -Identity �Prepare query suggestions�


To unblock the Query Suggestions "ford"

Remove-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $SearchApp -Language en-Us -Type QuerySuggestionBlockList -Identity �ford�
Start-SPTimerJob -Identity �Prepare query suggestions�

To view the list of blocked Query Suggestions

Get-SPEnterpriseSearchLanguageResourcePhrase �SearchApplication "SharePoint Server Search" -Language en-us -Type QuerySuggestionBlockList

WARNING: column "Mapping" does not fit into the display and was removed.

Phrase               Type                                        Culture    Author
------               ----                                             -------       ------

ford                 QuerySuggestionBlockList            en-US      domain\user


An unexpected error has occurred when trying to create an Enterprise Search Center in SharePoint 2010

Issue Description

I tried to create a SharePoint Search Center with site template as Enterprise Search Center within a site collection in SharePoint 2010 and got the below error.




Reason

The SharePoint Server Publishing Infrastructure feature must be activated at the site collection level before creating a site with Enterprise Search Center template.

Resolution

So the next step was to enable the Publishing Infrastructure feature.
1) Go to Site Actions -> Site Settings -> Site collection features -> SharePoint Server Publishing Infrastructure

2) Click on Activate



Tuesday, December 16, 2014

SharePoint 2010 Search Query Suggestions

SharePoint Query suggestions (or Search suggestions), appear below the Search Box Web Part and on the search results page.



So how do we get these query suggestions? There are 2 ways to do this :

1) The first one is created automatically based on user searches.

Query suggestions depend on users' searches. Only search queries that have been previously returned and then clicked through at least six times will appear in either the search box list. Therefore, a newly deployed SharePoint Server 2010 system will not show query suggestions in either location. Moreover, a query suggestion will only appear in the search box list if the query suggestion contains at least one of the words that are typed.

2) The second once is created manually.

We can use Windows PowerShell to manually add query suggestions. The benefit of this method is query suggestions are available immediately to users of a newly installed search system. We can also supplement the default Microsoft SharePoint Server 2010 behavior by adding query suggestions for key search terms.
In this manner, you can provide query suggestions that might not be generated by the system because users are not using the search terms that would create the query suggestions that you want to appear.

PowerShell to do this:

Here we are adding the following query suggestions manually (ford, test1, test2)

$searchapp = Get-SPEnterpriseSearchServiceApplication -Identity "<SearchServiceApplicationName>"

New-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $searchapp -Language En-Us -Type QuerySuggestionAlwaysSuggest -Name "ford"

New-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $searchapp -Language En-Us -Type QuerySuggestionAlwaysSuggest -Name "test1"

New-SPEnterpriseSearchLanguageResourcePhrase -SearchApplication $searchapp -Language En-Us -Type QuerySuggestionAlwaysSuggest -Name "test2"

Start-SPTimerJob -Identity "prepare query suggestions"


There are options to turn off query suggestions so that they will not appear at query time. This is made possible by editing the Search Box Web Part.



Tuesday, August 5, 2014

Hiding SharePoint Search Center Title and Description

1. Browse to the Page -> Edit Page -> Add Web Part -> Media and Content -> Content Editor -> Click here to add content-> On the ribbon -> HTML -> Edit HTML Source

2. Paste the below code :

<style>
.s4-mini-header {
            VISIBILITY: hidden
}</style><style>
.s4-mini-titlesep {
            VISIBILITY: hidden
}</style>


3. Content Editor Web Part ->Edit Web Part properties -> Appearance -> Chrome Type -> None


4. Page -> Publish 

Thursday, November 7, 2013

The object was not found. (Error from SharePoint site: HttpStatusCode NotFound The request failed with HTTP status 404: Not Found.)

I was checking the crawl logs for my Search Service application and was seeing the below error many times

The object was not found. (Error from SharePoint site: HttpStatusCode NotFound The request failed with HTTP status 404: Not Found.)

Cause

This because a file that was previously stored in Sharepoint and the crawler couldn�t find the object anymore. This could have been because the file was deleted or the access was denied. So the crawler would keep on trying to crawl the object for 30 times or 720 hours.

When the crawler encounters an access denied or a file not found error, the item is deleted from the index if the error was encountered in more than ErrorDeleteCountAllowed (the value for this is 30) consecutive crawls AND the duration since the first error is greater than ErrorDeleteIntervalAllowed (the value for this is 720 hours or 30 days). If both conditions are not met, the item is retried.

We can manage this deletion policy at the service application level to specify how many times and how long an item will be retried in consecutive crawls. This policy existed in Microsoft Office SharePoint Server 2007, but you could not view them nor change their values.

Resolution

Either you wait for 30 days for the errors to go away or you modify the default values.

$ssa = Get-SPEnterpriseSearchServiceApplication

To view the current value of a property:

$ssa.GetProperty("<PropertyName>")

To change the value of a property:

$ssa.SetProperty("<PropertyName>", <NewValue>)

The Property Name here would be ErrorDeleteCountAllowed and ErrorDeleteIntervalAllowed 



Read this article in TechNet to know more about the other deletion policies in SharePoint 2010 Search


Propellerads