403 when accessing ExplainRank.aspx in SharePoint

October 8, 2013

One of the most recent projects I have been working on is a SharePoint 2013 public facing web site. The site has been live for a while but the client recently reported the search results were not returning in the order they expected.

I checked the search results page and it was sorting by rank so I decided I should invest some time looking at how the SharePoint ranking model works and what I can do to impact this. While there is a lot of information out there I found it difficult to grasp how all these factors were combining in my environment, especially when things like number of page clicks can influence the ranking.

After some further research I found a link by Waldek Mastykarz Understanding item ranking in SharePoint 2013 Search. This is an excellent article which documents this very useful feature, however when I tried to access this on my environment I got an error, see figure 1.

image

Figure 1

As with all SharePoint problems I jumped on the server and started up ULS Viewer and hit the page again. I have a quick look through the logs and the item displayed in figure 2

image

Figure 2

I had a check on the site and I was a site collection admin so next I opened central admin and navigated to the service application list. Once there I selected my search service application by clicking next to the name, see figure 3.

image

Figure 3

Once selected I then clicked on administrators in the ribbon, see figure 4

image

Figure 4

In the popup I added my account as an admin and when I refreshed my explainrank.aspx page it now worked. While its not difficult to work out what the error is on the page I thought I would quickly blog this for others and myself, oh and if anyone from Microsoft reads this you could use a better error message on the page 🙂

Advertisements

SharePoint 2013 Search Web Part Missing Results

April 26, 2013

While working on a few SharePoint 2013 projects I have been utilising the SharePoint search in a lot of places to provide dynamic content and there has been quite a few occassions when things don’t seem to work as expected such as CBS Server Side Date Error or Results web part ordering. I suppose this is to be expected when the search engine has been completely replaced with a mix of the old SharePoint search engine and FAST search.

When working on one aspect of a recent project I was using the results script web part to query some events stored in a list. As per you would expect these events had the typical details such as title, date, description, etc. At first everything seemed to be working as expected until the client reported there was a bunch of events missing from the search generated list. My first thought was these were new events and weren’t in the search index so I kicked off a full crawl. Once this was completed I checked the site and the events were still missing.

Next I looked at my query to see if there was something wrong with it. For example I was filtering out all past events and restricting the search results to the events content type but everything seemed ok.

I spent some time looking around and eventually I noticed that the missing items were very similar to other items which were getting displayed in the search list. There would be 4/5 events in the list with the same title and description but with different dates or locations. I had a look at the web part properties and I noticed there was an option to show a link to display duplicate results, see figure 1.

WebPartProperties

Figure 1

I selected this option but it never done anything. From previous experience with some web parts I knew there are sometimes web part properties which are not exposed via the UI which can still be set if you export the web part, a good example of this is to get the Content By Search web part to run server side. I exported the web part and opened this with notepad and searched for “Duplicate”. Wouldn’t you know it there was a boolean flag in the DataProviderJSON property called TrimDuplicates and this is defaulted to true, see snippet below in figure 2.

<property name="DataProviderJSON" type="string">{"QueryGroupName":"Default","QueryPropertiesTemplateUrl":"sitesearch://webroot","IgnoreQueryPropertiesTemplateUrl":false,"SourceID":"8413cd39-2156-4e00-b54d-11efd9abdb89","SourceName":"Local SharePoint Results","SourceLevel":"Ssa","CollapseSpecification":"","QueryTemplate":"ContentTypeId:0x0100440D27D8CDA949078CD3C29F3F3D7012*{searchboxquery}","FallbackSort":null,"FallbackSortJson":"null","RankRules":null,"RankRulesJson":"null","AsynchronousResultRetrieval":false,"SendContentBeforeQuery":true,"BatchClientQuery":true,"FallbackLanguage":-1,"FallbackRankingModelID":"","EnableStemming":true,"EnablePhonetic":false,"EnableNicknames":false,"EnableInterleaving":true,"EnableQueryRules":true,"EnableOrderingHitHighlightedProperty":false,"HitHighlightedMultivaluePropertyLimit":-1,"IgnoreContextualScope":false,"ScopeResultsToCurrentSite":false,"TrimDuplicates":true,"Properties":{},"PropertiesJson":"{}","ClientType":"","UpdateAjaxNavigate":true,"SummaryLength":180,"DesiredSnippetLength":90,"PersonalizedQuery":false,"FallbackRefinementFilters":null,"IgnoreStaleServerQuery":false,"RenderTemplateId":"DefaultDataProvider","AlternateErrorMessage":null,"Title":""}</property>

Figure 2 – Please note this has the QueryTemplate element remove so the exact query being executed isn’t visible to others 🙂

Most of the snippet above is default settings which you can ignore the import one is TrimDuplicates. In my case as soon as I set the this to false, saved the web part, imported it into the web part gallery and added it to a page all my results started to display correctly.

The key element here is how SharePoint determines if items are duplicates and in my case I suppose it’s fair enough as most of the key information such as the title and description were pretty much exactly the same.

This is another classic example of SharePoint and how its working as expected but because there are 101 configuration options you are not getting the results expected. It’s important to fully understand the product and all the options and what it can offer. This is one I will not forget and hopefully it provides a prompt for others in a similar situation.


SharePoint 2013 search results web part ignores sort order entered via Query Builder

November 22, 2012

I have been working with SharePoint 2013 since it was released a few weeks ago and even before that when it was still in Beta and if I’m honest I have been slightly disappointed. There are some great new features which have been added to the product but I have found there are certain elements which just don’t work as I would expect and this blog post is about one of these issues.

I am currently working on a project for a public facing website which is built on SharePoint 2013 and one of the components is to display the latest news. The news content is stored in a list and I decided to use the ResultScriptWebPart rather than writing some custom code or using the ContentBySearchWebPart or ContentByQueryWebPart to display the news items.

I added the search results web part to the news page and opened the ‘Change ‘Query’ popup in the web part properties, see figure 1.

SearchResultsChangeQueryButton

Figure 1

I then configured my search criteria using the advanced mode settings, see figure 2.

SearchResultsAdvancedSettings

Figure 2

Next I clicked on the ‘Sorting’ tab and entered the sort criteria I wanted the results to use, see figure 3.

SearchResultsSorting

Figure 3

Once I was happy with the query and the sorting options I tested my query by clicking on the test tab and checking the results I expected were return and they were in the correct order, see figure 4 for screen without any results for privacy reasons

SearchResultsTesting

Figure 4

At this point the query and sort order had been set and it was returning the correct results in the preview. When I saved the settings and returned to the page I noticed that while there were results they weren’t in the order I specified.

I spent ages checking settings and looking around but nothing I changed seemed to make a difference. Eventually just for testing I enabled the sort dropdown and noticed when this was on the page I was able to select different options from the drop down and this altered the sorting. From looking at the options in the drop down, see figure 5, it looked like these options were being pulled from the ‘Available sort orders (JSON)’ web part property under settings.

SearchResultsFilterDDLOptions

Figure 5

As soon as I looked at the options in the ‘Available sort orders (JSON)’ web part property it occurred to me that for some reason the web part ignores whatever you set in the actual query builder and only sorts based on the values in this property. I changed this to sort on the fields I wanted, see figure 6, and the results came back in the correct order.

SearchResultsJSONSort

Figure 6

There may be some setting I am missing but to me this seems backwards in that you can set the sort order in the ‘Change Query’ settings and they have a nice UI for it and it even uses these settings in the preview but as soon as you save the settings it sorts on the ‘Available sort orders (JSON)’ web part property. If anyone has any experience of this and there is another way around it please let me know


%d bloggers like this: