Duplicate search results when using MS Graph API Search

Andrei Nita 0 Reputation points
2024-07-29T12:04:04.77+00:00

I have an SPFx web part that retrieves all list items in SharePoint via search and lists them in a table. At one point, I have noticed that I was getting duplicate results from the search call (using the MS Graph API). I have tried to add the trimDuplicates attribute to the search request, as well as switch the client version to beta, but neither of those solved my issue. The search request body that I am using is the following:


{
    "requests": [
        {
            "entityTypes": [
                "listItem"
            ],
            "query": {
                "queryString": "promotedState=0 OR promotedState=1 OR promotedState=2"
            },
            "trimDuplicates": true,
            "size": 400,
            "fields": [
                "title",
                "promotedState",
                "path",
                "uniqueid"
            ]
        }
    ]
}

I was successful in reproducing this issue in the MS Graph Explorer too, by using the same query.

In my case, one of the the duplicate results I am getting is found at rank 1 and 14 of the search results. Same data, same hit ID, but 2 different ranks.

To my knowledge, this is happening for every item returned by Search. Every single result seems to show up 2 times.

I have validated this on 3 separate environments, and I believe this might be an issue with the MS Graph API.

I have switched out the implementation of the search call to use the SharePoint REST API, and this issue did not reproduce anymore.

Is there a reason for the MS Graph API to have this behavior?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,279 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,832 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
3,044 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Emily Du-MSFT 47,301 Reputation points Microsoft Vendor
    2024-07-30T08:38:26.4366667+00:00

    You could use following search request. It does not duplicate search results.

    {
        "requests": [
            {
                "entityTypes": [
                    "listItem"
                ],
                "query": {
                    "queryString": "promotedState=0 OR promotedState=1 OR promotedState=2"
                },
                "trimDuplicates": true,
                "fields": [
                    "title",
                    "promotedState",
                    "path",
                    "uniqueid"
                ]
            }
        ]
    }
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    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.


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.