Is there a way to override preset parameters query...
# community-help
t
Is there a way to override preset parameters querytime through the body? If we have created a multi_search preset, it seems it is only possible to override parameters through the querystring. How do you then target and override specific facet searches in a multi_search preset?
j
Search parameters specified in the multi_search body or url query params should override the search parameters inside the preset...
If that doesn't work as expected, could you share a set of curl commands like this that replicates the issue?
t
Ok, will do 👍
curl 'https:// ${API_URL}/multi_search?preset=${PRESET_NAME}' \ --header 'X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}' \ --header 'Content-Type: application/json' \ --data '{ "searches": [ { "q":"surf" } ] }'
the response is "Parameter
q
is required."
j
Could you also share the output of
GET /presets
?
t
{ "name": "{preset_name}", "value": { "searches": [ { "collection": "{collection_name}", "prioritize_exact_match": "false", "query_by": "name,Brand,Categories,Color", "query_by_weights": "1,1,1,1", "sort_by": "_text_matchdesc,raptor rankdesc,SpecialPrice:asc", "split_join_tokens": "always" } ] } },
j
So this is a multi_search preset meaning that, when provided, it will fully override the body post body. You want to use a single search preset if you want the override behavior, and use that preset name inside the post body
So the preset would be in this structure:
Copy code
{
  "name": "{preset_name}",
  "value": {
    "collection": "{collection_name}",
    "prioritize_exact_match": "false",
    "query_by": "name,Brand,Categories,Color",
    "query_by_weights": "1,1,1,1",
    "sort_by": "_text_match:desc,raptor_rank:desc,SpecialPrice:asc",
    "split_join_tokens": "always"
  }
}
And then you can use inside a multi_search request like this:
Copy code
curl 'https:// ${API_URL}/multi_search' \
--header 'X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}' \
--header 'Content-Type: application/json' \
--data '
{
  "searches": [
    {
      "q": "surf",
      "preset": "{preset_name}"
    }
  ]
}
'
t
Ah, that was it. It works now! thank you
👍 1