SharePoint Search Results Limit People results to only 5 + Show Other items (docs, sites etc)

R, Naveen 41 Reputation points
2021-10-12T09:51:30.573+00:00

Can you please help me in formulating a KQL or FQL query?

Retrieve only 5 people results from the below query. Rest of the items can be anything from the index of the SharePoint Search Service.

{?{searchTerms} ContentClass=urn:content-class:SPSPeople TOP 5}

Here Top 5 refers only to People results.

Example - If a page has total 20 items (max items per page), I need to display 5 people results + 15 other items like docs, folders, links, sites only in the first page (Similar to SP Online OOTB Search Page ALL Tab)

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
11,109 questions
{count} votes

Accepted answer
  1. CaseyYang-MSFT 10,456 Reputation points
    2021-10-13T08:06:07.473+00:00

    Hi @R, Naveen ,

    You could try to use "OR" PHRASE: or(term, term [,term]*). For example: {?{searchTerms} ContentClass=urn:content-class:SPSPeople TOP 5} {?OR (({searchTerms}) contentclass:STS_List_DocumentLibrary AND Path:site url)}

    For Reference: Mix two Result Sources in Search Results Web Part
    Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.


    If an Answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


1 additional answer

Sort by: Most helpful
  1. R, Naveen 41 Reputation points
    2021-10-18T06:34:46.107+00:00

    @CaseyYang-MSFT,

    Now I am trying to achieve this using Search API.

    /_api/search/query?querytext='Query-Text'&sourceid='B09A7990-05EA-4AF9-81EF-EDFAB16C4E31'&rowlimit=5&sortlist='Rank:descending'

    Where sourceid='B09A7990-05EA-4AF9-81EF-EDFAB16C4E31' corresponds to People Result Source ID

    But, the sort on Rank is not working. How do we sort by Default Ranking Model? Can you please help here.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.