SharePoint 2013 Search not displaying all results

This is a live project issue that just came across today, so thought of sharing with everyone!!

images (1)

If we have a search based application in SharePoint 2013, we can retrieve search based results by either using a Search Results web part or a Content by Search web part.

Problem Statement:

If we configure both the web parts to have same query and result source, we should be receiving same results set and count.

However, Content by Search web part returns all results as expected, but search results web part was only returning few of the results. It surely is not a problem of crawl as data is present on the site and is being displayed using the other web part.

So what could be the issue?

Conclusion & Solution:

In the earlier versions of the Search Result Web Parts, the user had an option to “Trim Duplicates” which is no longer present in the SharePoint 2013 Search Result Web Part’s properties.

There is a way to set the Trim Duplicates property to false. Sharing the steps below:

  1. Export the Search Results Web Part from your page.
  2. Open the .webpart file in your favorite editor.
  3. Search for “Trim Duplicates”, you will find it as part of the DataProviderJSON property.
  4. Set the Trim Duplicates property to False.
  5. Upload the web part.
  6. Add the web part to your page.

image

SharePoint excludes the content that it thinks is similar. Even though the pages have a unique name and the content might not be the same, if it has some content that is similar, then search will collapse them in the result set.

Once the Trim duplicates option is set to false, you will get the results that you would expect and the result set from a Content By Search web part will match the result set from a Search Result web part

Setting up Provider Hosted Apps environment for SharePoint 2013

Hi All,

As we all know, setting up Provider hosted app in SharePoint 2013 environment can be a pain at times.

We all have come across various issues while setting this up.

Sharing a self created and tested document with step-by-step approach to set this up and create a provider hosted app.

Any suggestions, thoughts or comments are appreciated!!!

developing-a-provider-hosted-sharepoint-app-7-638

Click here to go through the complete step by step details to get this implemented

SettingUp_ProviderHostedApp

Cheers !!

SharePoint Crawl DB size increasing @20GB per day

Recently, one of my SharePoint farms faced an issue where the volume utilization of DB server (SharePoint crawl database) went upto 99% within 10 days.

Analysis:
– Looking at the crawl DB log in SharePoint, the incremental crawl was running every 1.5 hours with 0 success and 100% failures.

– There were about 961K errors with each incremental crawl scheduled at every 2 hours.

– There is a temporary folder that Crawl uses to place files temporarily on the server. The path is C:\Users\”SPAdminAccount”\AppData\Local\Temp\gthrsvc_OSearch14\

– I found out that this temporary folder was somehow missing / deleted.

Solution:

On creating the above mentioned folder manually, the success rate of crawl went high and there were very less failures (as expected)

Post this, the space utilization went about 10 MB a day which is expected during crawl.

CAML Designer 2013

For any SharePoint developer, CAML Query builder has always been a tool used very frequently for development of custom SharePoint solutions.

With SharePoint 2013 CAML Designer:

  • you can build CAML queries for single lists
  • you can build queries that can be executed with SPSiteDataQuery
  • beside the pure CAML queries, you can also get code snippets for the server-side object model, the .NET client-side object model, the JavaScript client-side object model and last but not least code snippets when working with REST.
  • Autogenerate the actual CAML Query
  • Autogenerate Server OM code
  • Autogenerate CSOM .NET code
  • Autogenerate CSOM REST code
  • Autogenerate Web Service code
  • Autogenerate PowerShell code

Map SharePoint library to Network Drive

Sometimes it becomes necessary to map a SharePoint document library as a network drive. This may be a customer requirement, or developer requirement to manage the SharePoint folder structure.

Sharing the steps below for the same:

Step 1:
Note down the document library’s site path which needs to be mapped as a network drive.

Example: https://home.intranet.com/departments/finance

Step 2:
Open File explorer, Right click, Select – Add Network Location




Step 3:
Click Next, and select option – Choose a custom network location, select Next.

Step 4:
Enter the SharePoint site URL. Click Next

Step 5:
It should prompt for credentials to connect to the SharePoint site. Enter Administrator credentials along with domain name.
It will ask for a name to be provided for this network drive location. Provide a custom name e.g. Finance Site.

Press Next.

Step 6:
It should now open the mapped drive location along with lots of folders. These folders represent all the lists and libraries contained in this SharePoint site.
You should also be able to view the Document library here.

Delete default page (Default.aspx) created on publishing site during site provisioning

In case of certain scenarios, like when we create a publishing site, or when we create a site definition and activate the publishing feature, a default.aspx page is created.
If we are using a custom page as welcome page for the site, we can delete the default.aspx page during provisioning of the site.

We can add the code for this in Feature Receiver.

SPList objPagesList = null;              
Guid ListId;
//Get the Pages List for current Locale
ListId = PublishingWeb.GetPagesListId(web);
objPagesList = web.Lists[ListId];
//Get the URL of the default.aspx page to be deleted
string urlPagetoDelete = objPagesList.RootFolder.ServerRelativeUrl + “/default.aspx”;
if (web.GetFile(urlPagetoDelete).Exists)
{
    SPFile objFile = objPagesList.RootFolder.Files[“default.aspx”];
    if (objFile != null)
    {
         if (objFile.CheckOutStatus == SPFile.SPCheckOutStatus.None)
         {
              objFile.CheckOut();
         }
         objFile.Delete();
    }
}

Assign default page of Publishing site to custom page during site provisioning

In my previous post, I have highlighted how to create pages in Pages library using CAML when a site is being provisioned.
We had created Home.aspx custom page.
 

Requirement:

We need to set Home.aspx as the default welcome page of the site, when the site is being provisioned.

Solution:
We can achieve this by putting a piece of code in the feature receiver.

//Get the Publishing Web object
PublishingWeb objPublishingWeb = PublishingWeb.GetPublishingWeb(web);
//Get the Home.aspx file from Pages library
SPFile objHomePageFile = web.GetFile(objPublishingWeb.PagesListName + “/Home.aspx”);            
//Set default page of publishing web
objPublishingWeb.DefaultPage = objHomePageFile;
objPublishingWeb.Update();
web.Update();
  
If we browse the site now, Home.aspx opens up as the default page.