Max Priazhevskii
05/21/2025, 2:24 AMbestseller.{store}
fields (one per region). We want a single override that promotes or demotes bestsellers for certain searches/filters, picking the right bestseller.{store}
field based on the visitor’s store, which we can pass within the search query somewhere. Kinda like dynamic filtering, but for sorting.
What’s the best approach? And would it make sense to add this as a TS overrides feature?Kishore Nallan
05/21/2025, 3:50 AMsort_by
clause -- have you tried using that along with override tags? https://typesense.org/docs/28.0/api/curation.html#add-tags-to-rulesMax Priazhevskii
05/21/2025, 4:01 AMKishore Nallan
05/21/2025, 4:02 AMMax Priazhevskii
05/21/2025, 4:15 AM"rule": {
"filter_by": "category:=`wine` && store:={store}",
"tags": ["bestsellers"]
},
"sort_by": "bestseller.{store}, newest.{store}",
^ so to apply this override dynamically to all stores when a search query contains a tag and a store “var” in the filterKishore Nallan
05/21/2025, 4:17 AMKishore Nallan
05/21/2025, 4:18 AMKishore Nallan
05/21/2025, 4:18 AMMax Priazhevskii
05/21/2025, 4:19 AMAlain Russell
05/21/2025, 4:28 AMAlain Russell
05/21/2025, 5:01 AMMax Priazhevskii
05/21/2025, 9:50 AMKishore Nallan
06/09/2025, 6:48 AMAlain Russell
06/09/2025, 7:13 AMKishore Nallan
06/11/2025, 12:31 PMAlain Russell
06/11/2025, 7:41 PMMax Priazhevskii
06/12/2025, 9:56 AM{
"excludes": [],
"filter_curated_hits": false,
"id": "dynamic-query",
"includes": [],
"remove_matched_tokens": true,
"rule": {
"match": "exact",
"query": "{region}"
},
"sort_by": "unitssold_region.{region}:desc",
"stop_processing": true
}
we get this error on search:
Could not find a field named `unitssold_region.{region}` in the schema for sorting.
the schema:
{
"facet": false,
"index": true,
"infix": false,
"locale": "",
"name": "unitssold_region",
"optional": true,
"sort": false,
"stem": false,
"stem_dictionary": "",
"store": true,
"type": "object"
},
{
"facet": false,
"index": true,
"infix": false,
"locale": "",
"name": "unitssold_region.QLD",
"optional": true,
"sort": true,
"stem": false,
"stem_dictionary": "",
"store": true,
"type": "int64"
},
{
"facet": false,
"index": true,
"infix": false,
"locale": "",
"name": "unitssold_region.NSW",
"optional": true,
"sort": true,
"stem": false,
"stem_dictionary": "",
"store": true,
"type": "int64"
},
Then the cluster crashed after adding the override with filter_by rule (the sorting override) - see attached stack trace. Anything else we can try?Kishore Nallan
06/12/2025, 9:59 AMMax Priazhevskii
06/12/2025, 10:01 AMKishore Nallan
06/12/2025, 10:19 AM"query": "{region}"
This actually tries to match a query word against a value in the field called region
-- this is how placeholders work. The original use case was to convert a query like {brand} phone
into a q=phone + filter_by=brand_name type of search request.
The region
field must exist in the schema.Max Priazhevskii
06/12/2025, 10:26 AMKishore Nallan
06/12/2025, 10:27 AMMax Priazhevskii
06/12/2025, 10:35 AMKishore Nallan
06/12/2025, 10:41 AMKishore Nallan
06/12/2025, 10:42 AMMax Priazhevskii
06/12/2025, 11:01 AMregion
string[] field and recreating the query_by override doesn’t resolve the error. Probably something is still missing?Kishore Nallan
06/12/2025, 2:56 PMKishore Nallan
06/13/2025, 5:17 AMCould not find a field named...
There are a number of things wrong with the setup:
1. The collection schema should have "enable_nested_fields": true,
otherwise the children of the object fields won't be discovered and added to the schema.
2. There is an override rule created by targeting "query": "{region}"
but the query is q=*
-- it won't match the ruleMax Priazhevskii
06/13/2025, 5:22 AMKishore Nallan
06/13/2025, 5:37 AMMax Priazhevskii
06/13/2025, 5:41 AM"enable_nested_fields": true,
and there is still an error for any search from *
to product NSW
. The search only works with enable_overrides:false
.Kishore Nallan
06/13/2025, 5:57 AMAlain Russell
06/16/2025, 9:34 PMKishore Nallan
06/17/2025, 4:07 AMKishore Nallan
06/17/2025, 5:46 AM29.0.rc30
Alain Russell
06/17/2025, 6:56 AMMax Priazhevskii
06/17/2025, 11:19 AMbestseller:region.qld
but not for bestseller:region.QLD
(see attached).Kishore Nallan
06/17/2025, 1:14 PMKishore Nallan
06/18/2025, 4:38 PMq=NSW
will be tokenized to a lowercase form, so it becomes nsw
. Now, when we try to look for a field called bestseller:region.nsw
that does not exist in the schema. So you have to use lower case field names if you want the override rule to be triggered. Likewise, in filter_by
use the lowercase form as well: filter_by=region:=qld
2. You have defined {"name": ".*", "type": "auto" }
-- this may not set sort: true
so better to set an explicit schema like this: {"name": "bestseller:region.*", "type": "string", "sort":true }
-- in general always prefer an explicit schema.
With these two fixes, it will work.Max Priazhevskii
06/18/2025, 11:43 PM"filter_by": "region:={region}"
override works for lowercase field names but not uppercase ones. I’ve attached an example with an explicit schema.
We can work around the casing issue on our end, just want to confirm this is expected for the filter_by overrides too.Kishore Nallan
06/19/2025, 4:54 AMMax Priazhevskii
06/19/2025, 5:44 AM