Custom Search Configuration In SharePoint Online

One of the handiest features that were added to a list or library is the in-place searchbox. The in-place searchbox allows you to quickly search for items or documents while staying in the list or library context (in previous versions, you were redirected to a search page).

Sometimes, we may have experienced some problems like not been able to retrieve the items we needed or even retrieving no items at all. These problems can be related to columns from your list that are not configured as searchable.

Before moving further, just to make clear we have Crawled Property for every list column which SharePoint creates by default and we need to create Managed property and associate that crawled property with the managed property. The only time a managed property is auto-created is if the column is a site column else you need to create managed property manually if you have local SharePoint column.

Note

You need to add at least one value for the field in the list in order to create Managed property.

Configuration Steps

Step 1

Create site column as "SL_Product" and create new document library/list from where we want to display records.

I am using "ManufacturingInstructions" as a document library. Add the site column inside the library. Add at least one record.

SharePoint  

Step 2

Navigate to Site Settings > Result Sources under Search > New Result Source.

Give name as Custom Search. Leave protocol and other fields as default.

Click on launch builder.

SharePoint  

Provide details as shown below. As you can see, it shows me one record inside the library which I added earlier.

SharePoint

Click OK and Save. Your result source is configured.

Note

If you want to filter specific to only list and library, you need to paste as below:

{searchTerms} {SearchBoxQuery}

path:https://<Tenant>.sharepoint.com/sites/QA/SL_MI/Lists/ArchivedMIs -Filename:AllItems path:https://<Tenant>.sharepoint.com/sites/QA/SL_MI/ManufacturingInstructions -Filename:AllItems IsContainer:false 

If we want to apply filter for document libary to not include AllItems or unnecessary file, it can be done with search synatx of,

{searchTerms}

Path:https://<tenant>.sharepoint.com/sites/QA/SL_MI -Filename:AllItems -Filename:aspx (contentclass:STS_List OR contentclass:STS_List_DocumentLibrary)

IsContainer:false

Step 3 - Search Scheme Configuration

Navigate to Site Settings > Search Schema under Site Collection Administration.

First, check if the crawled property was created successfully so that we can create a Managed Property for that column.

As we can see, it shows me crawled property for the column "SL_Product".

SharePoint  

Add new managed property. Provide property name and mark other option like "Searchable", "Queryable", "Retrieval" as checked. Provide "SLProduct" as Alias name.

Inside "Mappings to crawled properties" add "ows_SL_Product" under mapping and click save.

For create new refiners, search for any refinable string which is empty and Add a Mapping of the column by clicking on "Edit/Map Property" and add "ows_SL_Product" so that the result can be sorted on the product name.

Note

Here we have created two separate string, one for mapped property for searching/querying and other we mapped with existing refinableString for refining search. As in office 365, we cannot create new refinable string. We can only map with existing refinableString.

Step 4

Perform full indexing by navigating to Library Setting > Advance Settings > Reindex Document Library > Ok.

With this step, search configuration is done.

Step 5

Create a new page. Add Content Search on page > Edit Webpart > Change Query.

Select "Custom Search" under select a query as result source we created earlier. Leave others as default.> OK.

Add refiners on page, choose refiner and add the refiner we added for refiners. Click OK.

SharePoint

Let me know if you face issues.