#community-help

Resolving Typesense Query Issues

TLDR Todd had queries regarding Typesense operation. Jason clarified Typesense's default behavior and provided a recommendation to enhance results ranking based on relevance and recency.

Powered by Struct AI

1

Oct 10, 2023 (1 month ago)
Todd
Photo of md5-cccf0b87668408fef09dd77e1948fced
Todd
09:33 PM
Hey all, Typesense has been working great for some of our use cases, and its rapidly becoming irreplacable for certain types of queries. However, one of our product guys had some interesting questions I wasn’t so sure about!

• I noticed when we search for two words with a space separated, only the first word is highlighted. Any way to highlight both words?
• Is it possible to wrap both words in a quote or similar to only specify them together?
• Is it possible to weight results higher where the second word also matches?
Thank you as always, and sorry if I’ve asked any of these questions before already! 😬 :facepalm:
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
10:12 PM
> I noticed when we search for two words with a space separated, only the first word is highlighted
That doesn't sound like the default settings... For eg, here's one of our demos showing both words highlighted with the default settings. Could you share a curl command with all the query params you're using, minus the API key that shows this issue on your dataset?
Image 1 for > I noticed when we search for two words with a space separated, only the first word is highlighted
That doesn't sound like the default settings... For eg, <https://recipe-search.typesense.org/?r%5Bquery%5D=low%20carb|here's> one of our demos showing both words highlighted with the default settings. Could you share a curl command with all the query params you're using, minus the API key that shows this issue on your dataset?
10:12
Jason
10:12 PM
Is it possible to wrap both words in a quote or similar to only specify them together?
Yup, this is called phrase search, and is supported in Typesense, when you surround terms with "double quotes"
10:12
Jason
10:12 PM
&gt; Is it possible to weight results higher where the second word also matches?
this is the default behavior as well. Could you share a curl command that shows a different behavior?
Todd
Photo of md5-cccf0b87668408fef09dd77e1948fced
Todd
10:13 PM
Jason - Oh gosh, for the spaces, I bet its something with me not decoding the uri component right 😬
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
10:13 PM
Ah yeah, that could be an issue!
Todd
Photo of md5-cccf0b87668408fef09dd77e1948fced
Todd
10:14 PM
Our query is very plain, I don’t think we’re clever enough to break this stuff yet:

{
      filter_by: `...`,
      q: 'One two',
      query_by: '...',
      sort_by: 'timestamp:desc',
      per_page: PAGE_SIZE,
      page,
}
10:15
Todd
10:15 PM
Jason - Thank you for checking me on the system defaults! I’ll investigate how I’m handling spaces and such over the wire. Thanks!
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
10:16 PM
sort_by: 'timestamp:desc' will strictly order the results by timestamp... and could potentially rank results with higher relevancy further down, if they are more recent.

I'd recommend changing that to:

sort_by: '_text_match(buckets: 10):desc,timestamp:desc'

to interview relevance with recency
Todd
Photo of md5-cccf0b87668408fef09dd77e1948fced
Todd
10:18 PM
Jason - Thank you so much, this is awesome!

1

Typesense

Lightning-fast, open source search engine for everyone | Knowledge Base powered by Struct.AI

Indexed 3015 threads (79% resolved)

Join Our Community

Similar Threads

Phrase Search Relevancy and Weights Fix

Jan reported an issue with phrase search relevancy using Typesense Instantsearch Adapter. The problem occurred when searching phrases with double quotes. The team identified the issue to be related to weights and implemented a fix, improving the search results.

6

111
8mo

Adjusting Text Match Score Calculation in TypeSense

Johannes wanted to modify the Text Match Score calculation in TypeSense to improve search results returns. With counsel from Jason and Kishore Nallan, various solutions were proposed, including creating a Github issue, attempting different parameters, and updating Docker to a new version to resolve the matter.

3

48
19mo

Docsearch Scrapper Metadata Configuration and Filter Problem

Marcos faced issues with Docsearch scrapper not adding metadata attributes and filtering out documents without content. Jason helped fix the issue by updating the scraper and providing filtering instructions.

2

82
8mo

Typesense Performance with Large Datasets & Custom Sort

krok inquires about Typesense's performance on large datasets and custom sorting. Kishore Nallan explains that Typesense is optimized for this scenario using pagination and text relevance.

1

35
10mo

Understanding and Adjusting Query Parameter Weights

John needed help understanding default weights, manipulating weights, and sorting by weight in query parameters. Jason educated on default weights, sorting mechanism, and also suggested using buckets for sorting based on custom fields.

3

21
19mo