Skip to content

Search API - How to prevent duplicate results when using paging (StartRow, RowLimit) #10450

@diabhoil

Description

@diabhoil

What type of issue is this?

Question

What SharePoint development model, framework, SDK or API is this about?

💥 SharePoint Framework

Target SharePoint environment

SharePoint Online

What browser(s) / client(s) have you tested

  • 💥 Internet Explorer
  • 💥 Microsoft Edge
  • 💥 Google Chrome
  • 💥 FireFox
  • 💥 Safari
  • mobile (iOS/iPadOS)
  • mobile (Android)
  • not applicable
  • other (enter in the "Additional environment details" area below)

Additional environment details

Issue description

I have a document library with 599 documents which are more or less very similar. When I perform queries to the search REST API like below, I get - with 2 calls (500+99 entries) - TotalRows = 599 back. But that are not 599 unique rows. I get ~10-50 duplicate entries in the second call for the 99 results which I got in the first 500 rows already. How can I perform the query to get all 599 unique results back. And I already now about Pagination for large result sets, but when I use that, I lose the "default" sorting, because then everything is sorted by DocId.

//this is performed in loop to get more then 500 results
const searchResults = await sp.search({
          Querytext: `(ContentTypeId:0x010100010*) AND (Path:https://tenant.sharepoint.com/sites/XXXX*)`,
          StartRow: startRow,
          SelectProperties: ["Title", "Path", "UniqueID"],
          RowLimit: 500,
          EnableInterleaving: false,
          SourceId: "8413cd39-2156-4e00-b54d-11efd9abdb89",
          TrimDuplicates: false //true wont work here, because the documents are kinda alike
      });

Is there a property I have to set? To double check my results I have included the PnP Modern Search Webpart on one of my pages, displayed the results and checked if every entry on every page (100 entries per page) is unique. And there I got the same problem.

So the number of total results is always correct. But I never get all the unique 599 results back with paging.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions