Luke Hill
02/27/2025, 3:43 PM0
to 100_000_000
and in our UI we use a range slider to allow the user to select what prices they would like to see.
We then form a filter like so filter_by: price:[100..500000]
as an example.
We have about 3.5 million records and on average this search takes 1 second to complete.
Our current ideas are to try all of the following:
• Adding ranged_index
to the schema
◦ We’ve done this for part of our data set and so far we are only seeing a very small improvement
• Increase RAM
• Move to run in a VM
• Move to Typesense cloud
and if all of that doesn’t help, then we have thought about trying to turn it into a string based filter with a set of ranges, so something priced at 10
would be assigned priceFilter: '0'
(range 0 to 100) and something priced at 12000
would get priceFilter: '10000'
(range 10_000 to 20_000). We would then turn this into a filter like so filter_by: (priceFilter:='0' || priceFilter:='100' || priceFilter:='1000' || priceFilter:='10000')
We would like to avoid doing this though as it would be a huge undertaking to apply this new priceFilter
to all 3.5 million records.
If there is a better way or something that we are missing I would really appreciate some advice. Thanks in advance.Kishore Nallan
02/27/2025, 3:48 PMranged_index
does not help. Could it be possible that there are other parameters in the search query which is actually slowing it down (or maybe range_index in combination with those becomes ineffective)?Kishore Nallan
02/27/2025, 3:49 PMLuke Hill
02/27/2025, 3:53 PM40ms
improvement from ranged_index
although we’re not completely finished with our testing of that yetLuke Hill
02/27/2025, 3:53 PM97ms
curl '***/search/multi_search?use_cache=true' \
-H 'x-typesense-api-key: ***' \
--data-raw '{
"searches":[
{
"collection":"lots",
"exclude_fields":"footnotes,catalogDesc",
"filter_by":"(department.name:=Collector Cars) && (status:=NEW)",
"facet_by":"brand,country.name,country.code,department.code,department.name,flags.isWithoutReserve,price.GBPHighEstimate,price.GBPLowEstimate,price.estimateHigh,price.estimateLow,status,groups",
"query_by":"title",
"sort_by":"price.GBPLowEstimate:desc",
"page":1,
"per_page":48,
"max_facet_values":1000,
"q":""
},
{
"collection":"lots",
"exclude_fields":"footnotes,catalogDesc",
"filter_by":"(status:=NEW)",
"facet_by":"department.name",
"query_by":"title",
"sort_by":"price.GBPLowEstimate:desc",
"page":0,
"per_page":0,
"max_facet_values":1000,
"q":""
},
{
"collection":"lots",
"exclude_fields":"footnotes,catalogDesc",
"filter_by":"(department.name:=Collector Cars)",
"facet_by":"status",
"query_by":"title",
"sort_by":"price.GBPLowEstimate:desc",
"page":0,
"per_page":0,
"max_facet_values":1000,
"q":""
}
]
}'
Luke Hill
02/27/2025, 3:55 PM1470ms
curl '***/search/multi_search?use_cache=true' \
-H 'x-typesense-api-key: ***' \
--data-raw '{
"searches":[
{
"collection":"lots",
"exclude_fields":"footnotes,catalogDesc",
"filter_by":"(price.GBPLowEstimate:[0..276797] || price.GBPHighEstimate:[0..276797]) && (department.name:=Collector Cars) && (status:=NEW)",
"facet_by":"brand,country.name,country.code,department.code,department.name,flags.isWithoutReserve,price.GBPHighEstimate,price.GBPLowEstimate,price.estimateHigh,price.estimateLow,status,groups",
"query_by":"title",
"sort_by":"price.GBPLowEstimate:desc",
"page":1,
"per_page":48,
"max_facet_values":1000,
"q":""
},
{
"collection":"lots",
"exclude_fields":"footnotes,catalogDesc",
"filter_by":"(price.GBPLowEstimate:[0..276797] || price.GBPHighEstimate:[0..276797]) && (status:=NEW)",
"facet_by":"department.name",
"query_by":"title",
"sort_by":"price.GBPLowEstimate:desc",
"page":0,
"per_page":0,
"max_facet_values":1000,
"q":""
},
{
"collection":"lots",
"exclude_fields":"footnotes,catalogDesc",
"filter_by":"(price.GBPLowEstimate:[0..276797] || price.GBPHighEstimate:[0..276797]) && (department.name:=Collector Cars)",
"facet_by":"status",
"query_by":"title",
"sort_by":"price.GBPLowEstimate:desc",
"page":0,
"per_page":0,
"max_facet_values":1000,
"q":""
}
]
}'
Kishore Nallan
02/27/2025, 3:55 PM"max_facet_values":1000,Is probably taking the most time here.
Kishore Nallan
02/27/2025, 3:56 PM(price.GBPLowEstimate:[0..276797] || price.GBPHighEstimate:[0..276797])
Is probably something that query optimizer is not equipped to handle. ORing of two range queries.Kishore Nallan
02/27/2025, 3:57 PMLuke Hill
02/27/2025, 3:58 PMLuke Hill
02/27/2025, 3:58 PMmax_facet_values
please and what we could do to improve there?Kishore Nallan
02/27/2025, 3:59 PMmax_facet_values
generally having large values like 1000
can hurt if the facets are high cardinality in nature. Try reducing it to say, 10
and check what response time you get?Kishore Nallan
02/27/2025, 4:00 PMLuke Hill
02/27/2025, 4:00 PMcurl
with it reduced to 10 and it’s come down by approximately 200ms
but still on average about 1200ms
for the requestLuke Hill
02/27/2025, 4:02 PMLuke Hill
02/27/2025, 4:02 PMKishore Nallan
02/27/2025, 4:03 PMLuke Hill
02/27/2025, 4:03 PMKishore Nallan
02/27/2025, 4:03 PMLuke Hill
02/27/2025, 4:04 PM