Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.
When using the search plugin filtering by more than one field, results can return a totalDocs value higher than reality. Sometimes even higher than docs that exist.
5. Add following JSX to the same file to view totalDocs on the page:
```jsx
<div className="container mb-16">
<div className="prose dark:prose-invert max-w-none">
<h1 className="sr-only">Search</h1>
<Search />
</div>
+ <div>{posts.totalDocs}</div>
</div>
Go to search page on the local website and search 'dive'. You should see 2 results in the archive block but the totalDocs should read 3.
Which area(s) are affected? (Select all that apply)
Describe the Bug
When using the search plugin filtering by more than one field, results can return a totalDocs value higher than reality. Sometimes even higher than docs that exist.
Link to the code that reproduces this issue
https://github.com/TimLanzi/payload-search-bug
Reproduction Steps
/src/app/(frontend)/search/page.tsx
to add a filter oncategory.title
:Which area(s) are affected? (Select all that apply)
plugin: search
Environment Info