#community-help

Issues with Typesense Search Results Limit

TLDR Adrian is trying typesense for the first time and encounters an issue with search results being limited to 10 hits. Kishore Nallan suggests sending 'max_candidates: 1000' as a search option.

Powered by Struct AI
pray1
Mar 01, 2023 (7 months ago)
Adrian
Photo of md5-866ace8517f5800eea2a3e1f51a1bb2f
Adrian
02:54 AM
Hey there 👋 I'm trying typesense for the first time and for the purpose of learning I threw together a very simple collection with this schema:
{
    name: 'accounts',
    fields: [
        {
            name: 'username',
            type: 'string',
            facet: false,
        },
        {
            name: 'email',
            type: 'string',
            facet: false,
        },
    ],
}

And dumped a bunch of random data in there with that structure, if I use this code to search:
const accounts = await typesenseClient
            .collections<Omit<Account, 'password'>>('accounts')
            .documents()
            .search(
                {
                    q: 'Ma',
                    query_by: 'username',
                    page: 1,
                    per_page: 20,
                    include_fields: 'username',
                },
                {
                    cacheSearchResultsForSeconds: 0,
                }
            );

It will return ONLY 10 hits, even though I know for a fact there should be more documents with the username starting with Ma (same thing happens for different searches, it doesn't go over 10) - if the q param is set to * it will show all the 1K+ docs available in that collection.
What am I missing? I've followed the setup guide from here https://typesense.org/docs/guide/install-typesense.html#linux-binary
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
03:03 AM
Try sending 'max_candidates: 1000' as a search option.
pray1