#community-help

Creation of Scoped Search Key for Different Collections

TLDR Imtiaz inquired about creating a Scoped Search Key for different filters. Jason suggested generating one scoped API key for each collection, adjusting it within multi_search through the 'x-typesense-api-key' parameter.

Powered by Struct AI

1

4
2w
Solved
Join the chat
Nov 09, 2023 (2 weeks ago)
Imtiaz
Photo of md5-5c86b23fcf7d52313d7a346d8cc3e86b
Imtiaz
12:31 PM
Hi. Is it possible to create a to create a Scoped Search Key that applies different filters on different collections (eg filter by Role on one or more collection but dont apply any filters on other collections)?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
02:37 PM
No, but what you can do is to generate one scoped API key for each collection, and then set that inside each search inside multi_search using the x-typesense-api-key param
02:38
Jason
02:38 PM
Something like this:

{
  "searches": [
    {
      "query_by": "name,country",
      "x-typesense-api-key": "scoped-key-for-collectionA",
      "collection": "collectionA"
    },
    {
      "query_by": "name,brand",
      "x-typesense-api-key": "scoped-key-for-collectionB",
      "collection": "collectionB"
    }
  ]
}
Imtiaz
Photo of md5-5c86b23fcf7d52313d7a346d8cc3e86b
Imtiaz
02:39 PM
Thank you

1