#community-help

Issue with Search Term Results in Typesense

TLDR Dipankar had issues with specific search terms returning unexpected results. Kishore Nallan clarified why this may occur and how to fine-tune the behavior using the 'drop_tokens_threshold' parameter in Typesense.

Powered by Struct AI
+11
9
13mo
Solved
Join the chat
Aug 25, 2022 (13 months ago)
Dipankar
Photo of md5-5b972823ad64a4cfe9700cd5729e8061
Dipankar
12:50 PM
I have few document their title is like this
30 best safari camps and lodges for unforgettable safaris
Night Safari
Tiger safari in Ranthambore National Park
Maharajas Express

If I search for Safari all these appears but if I search safari holiday only the last one appears "Maharajas Express" Why is this happening?

here is my search Client setting
  additionalSearchParameters: {
    query_by: "title,standfirst,catTags",
  }
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
01:17 PM
👋 Can you post the other fields of the Maharajas Express document?
Dipankar
Photo of md5-5b972823ad64a4cfe9700cd5729e8061
Dipankar
04:29 PM
title: "Maharajas Express"

standfirst:"<p>Relive the era of the British Raj on this fabulously luxurious train – and discover the highlights of Rajasthan, from the Taj Mahal and the magnificent royal palaces, to tiger safaris at Ranthambore.</p>"

catTags:"Agra,Asia,Delhi,Golden Triangle,India,Jaipur,Rajasthan,Uttar Pradesh,Best things to do in Agra,Best things to do in Delhi,Best things to do in India,Best things to do in Jaipur,Bucket list experiences in India,Bucket list ideas,Great luxury train journeys,Travel bucket list,Unforgettable luxury train holidays"
Aug 27, 2022 (13 months ago)
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
12:19 AM
By default Typesense returns document's that contains all tokens in the query. In this case his record has both tokens and so return that and stop there. If you want all tokens to be processed, take a look at the drop_tokens_threshold search parameter. It will allow you to fine tune this behavior.
Dipankar
Photo of md5-5b972823ad64a4cfe9700cd5729e8061
Dipankar
06:39 AM
  additionalSearchParameters: {
    query_by: "title,standfirst,catTags",
    drop_tokens_threshold: 0,
  }
06:40
Dipankar
06:40 AM
I added drop_tokens_threshold to 0 but its doing nothing as far i can tell
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
06:41 AM
Must be greater than 1. By setting it to zero you are effectively disabling it.
06:41
Kishore Nallan
06:41 AM
From the docs:

> If at least drop_tokens_threshold number of results are not found for a specific query, Typesense will attempt to drop tokens (words) in the query until enough results are found. Tokens that have the least individual hits are dropped first. Set drop_tokens_threshold to 0 to disable dropping of tokens.
Dipankar
Photo of md5-5b972823ad64a4cfe9700cd5729e8061
Dipankar
06:43 AM
thank you.
+11