Hello, i am currently testing typesense locally on...
# community-help
n
Hello, i am currently testing typesense locally on my mac (i am still new to it). I installed it and migrated my data. In my schema i have this field:
{ name: "sku_raw", type: "string", infix: true },
i am testing a search query like this:
const res = await client.collections("products").documents().search({
"gdx",
query_by: "sku",
prefix: true,
per_page: 20,
page,
});
in my collection i have documents with sku like "gdx1234" and others like "ngdx1234". My expectation is to get all documents that have these patterns or at least get the ones that have sku field starting with "gdx". i am getting only 10 results even though i have 2557 documents with sku field starting with "gdx".
a
Hey @Nour Hajjaj For performance reasons, Typesense will limit results, returning after a few candidates have been found. To control this behaviour, you'll want to review the search parameters, especially max_candidates and exhaustive_search. But mind that these can increase your search time. Also, for a result like "ngdx1234," you would need the infix feature, which we don't recommend for large fields due to the processing cost. https://typesense.org/docs/29.0/api/search.html#query-parameters
n
i did the infix feature for the field. The max_candidates represents all the data that will be fetched right? regardless of the per_page parameter. like if max_candidates is 100 and per_page is 10, that means i will have 10 pages of results. page 11 will return empty. did i understand correctly ?
a
max_candidates
limits how many token candidates are considered during fuzzy search. E.g: For each query token (e.g., "steve" with
num_typos=1
), Typesense searches the index for similar tokens: - Exact match: "steve" - 1 typo: "steve", "stev", "stevea", etc. - 2 typos: (if allowed) Query:
"steve jobs"
with
max_candidates=4
,
num_typos=1
For token "steve": - Finds: ["steve", "stev", "stevea", "steven"] (4 candidates) - Stops searching after finding 4 candidates
n
how can i fix it to get all candidates in my data ? i tried to use
exhaustive_search
but it override the whole search somehow, it wasn't searching based on the keyword given
a
Could you share your use case for wanting all results? Usually you will want a 2 or 3 pages worth of relevant results, instead of exhaustively get all of them. In this case you can try increasing max_candidates to something like 10, and tweak the other parameters, such as
drop_tokens_thresholds
,
num_typos
and so on https://typesense.org/docs/29.0/api/search.html#typo-tolerance-parameters
n
i have an ecommerce website, when the customer searches fr something i want to get all possible data for it. okay i will try, thank you
f
E-commerce stores tend to have the
found
parameter be exposed to the UI, and then either paginate through the number of pages or through cursor based pagination.