Query rule results block gives unexpected results when searching for "sharepoint"

I want to have a custom results page that lists documents only, and not web pages. Furthermore it should list specific document types.My first thought was to use the Documents results source, however as this does not include {searchBoxQuery} or {searchTerms} in it's query text that was not much use.

I copied the Documents result source, creating MyDocuments result source, and changed the query to be this:

{?path:{Scope}} {?owstaxIdMetadataAllTagsInfo:{Tag}} {?{searchBoxQuery} (FileExtension:doc OR FileExtension:docx OR FileExtension:xls OR FileExtension:xlsx OR FileExtension:ppt OR FileExtension:pptx OR FileExtension:pdf) (IsDocument:"True" OR contentclass:"STS_ListItem")}

I then created a new page, added a search core results web part, set MyDocuments to be to result source to use, published the page and it all worked fine. I could enter a text fragment or someone's name as a search box query and I would get back exactly what I expected.

The next step was to add a result block on top of search results to show documents authored by a person if someone's name was entered into the search box. This is a similar approach to the "Documents by" results block in the Local SharePoint Results query rule list.

I created a query rule for MyDocuments to do an exact dictionary query match again people names. I then added a results block with the following query:

Author:"{subjectTerms}" XRANK(cb=5000.00)

using MyDocuments as a result source for the query rule. My thinking was that the result block would execute the query against MyDocuments source, find documents that the named person had authored and display the documents. I configured the result block to have a title of

Documents by "{subjectTerms}"

This did work, I could enter people's names and it would show a results block of documents they had authored with a "more" link.

However the problem is that when I enter a specific search term, that search term being "sharepoint", the results block appears with Documents by "sharepoint" and a couple of documents that were not authored by an author named "sharepoint". Furthermore if I execute a query using:

Author:sharepoint

I get no results, which is what I would expect.

So the question is why do I get a results block when I enter "sharepoint" as a search term? We do have functional users in our AD with "sharepoint" in the name and these have manifested as profiles in the people service following an AD sync. However, given that a query of "Author:sharepoint" returns no results, I don't understand why I am getting a results block for that search term.

The concern is that because I don't understand why I am getting the result block appear, it could appear for other search terms.



  • Edited by Heley Wednesday, May 20, 2015 10:33 AM
  • Changed type Heley Friday, May 22, 2015 11:49 AM I got it wrong the first time
May 20th, 2015 9:01am

I found the solution. I added the following to the query of the result source:

-ContentClass=urn:content-class:SPSPeople

It appears that unless told otherwise, SharePoint search will include objects from the SPSPeople source. So what I think was happening was this:

  1. Query term contains "sharepoint".
  2. The result source returns people who have "sharepoint" in their profile somewhere, e.g. interests field.
  3. Result block executes a query that returns documents where the people in the result source are included in the query.
  4. Documents are returned from the result block query.
  5. Result block is shown with "sharepoint" as the author.

Step 3 is a guess based on what I observed in that the documents within the result block are all authored by a user that has the word "sharepoint" in their profile somewhere.

It would be great if someone from MSFT could confirm this theory, or say why it is wrong and explain what is going on. But at least we have solved the problem now.

  • Marked as answer by Heley Friday, May 22, 2015 11:49 AM
Free Windows Admin Tool Kit Click here and download it now
May 21st, 2015 8:20am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics