Hello Community, I have a question regarding the ...
# community-help
a
Hello Community, I have a question regarding the query suggestion. Is there any OOTB feature / custom solution in TS, where I can show end users some query suggestion based on what he is typing? it should meet the following criteria: 1. It should be as precise as possible (i.e. q-> auto, results -> automotive, automatic, automation etc, q-> car auto, results -> car automotive, car automatic, car automation etc). 2. Suggestion should result in having one or more actual results. That means, the above suggestions automotive, automatic, automation should come from my primary index, so that when i search using any of the keyword it is guaranteed to be returned some results. I know, that TS has a built-in popular queries mechanism, but that is not appropriate in my scenario, as it does not guarantee any actual result in my primary index. My current implementation is to query the primary index for page title attribute , and return the records. Results are guaranteed, but most the time it has a full sentence / large number of words, which defeats the purpose. Thanks in advance.
j
My current implementation is to query the primary index for page title attribute , and return the records.
This would indeed be the solution.
Most the time it has a full sentence / large number of words
You can set
per_page
to say
4
to show users only the top 4 results. You can also use the snippet field in the response, to only show the most relevant part of the field to the user
a
Hi Jason, • You can set
per_page
to say
4
to show users only the top 4 results. Yes, but the number of results is not the concern here, but rather the number of words are. • You can also use the snippet field in the response, Yes, but in that case, I may see the same snippet word multiple times. You can take a look at the image. the snippet wraps around the same word. is there a way to increase/decrease the amount of letters to be snipetted?
j
highlight_affix_num_tokens
will control the length of the snippet, documented in this table: https://typesense.org/docs/0.25.0/api/search.html#results-parameters