#community-help

Difficulty Creating Override on Typesense's Curation API

TLDR Kor was facing trouble while creating an override on Typesense and not getting expected results. Jason assisted in debugging the issue, provided a fix with an upgrade, and confirmed some limitations regarding case sensitivity and bulk deletion of overrides.

Powered by Struct AI

2

25
4mo
Solved
Join the chat
Jul 26, 2023 (4 months ago)
Kor
Photo of md5-894e524356146cb346abbb1f595710f0
Kor
01:06 PM
Hi, I am trying to create an override (https://typesense.org/docs/0.24.1/api/curation.html#create-or-update-an-override) but I have the feeling I am not understanding how it works.

I managed to import an override via curl, and I can see it show up in the Typesense's admin (in the browser).
This is the object I import:
'{
"rule": {
"query": "revoke digital certificates and manage public-key encryption",
"match": "exact"
},
"includes": [
{
"id": "30642",
"position": 1
}
]
}'

I was expecting to see the “id” back in the admin, but it is not there. If I remove “content” by clicking on the cross, the id shows in the empty field, but disappears again after saving. What am I doing wrong?
Image 1 for Hi, I am trying to create an override (<https://typesense.org/docs/0.24.1/api/curation.html#create-or-update-an-override>) but I have the feeling I am not understanding how it works.

I managed to import an override via curl, and I can see it show up in the Typesense's admin (in the browser).
This is the object I import:
`'{`
  `"rule": {`
    `"query": "revoke digital certificates and manage public-key encryption",`
    `"match": "exact"`
  `},`
  `"includes": [`
    `{`
      `"id": "30642",`
      `"position": 1`
    `}`
  `]`
`}'`

I was expecting to see the “id” back in the admin, but it is not there. If I remove “content” by clicking on the cross, the id shows in the empty field, but disappears again after saving. What am I doing wrong?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
04:28 PM
Kor Could you DM me your cluster ID?

That view should at least show the ID of the record, so need to take a closer look
Kor
Photo of md5-894e524356146cb346abbb1f595710f0
Kor
04:36 PM
DM sent.
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
04:40 PM
Ah looks like the issue happens if the field chosen in “query by” has a null value for the pinned record. Will fix this.

On a side note, this is only a UI issue. The curation rule itself should work, since it only stores the ID of the document
Kor
Photo of md5-894e524356146cb346abbb1f595710f0
Kor
04:41 PM
Thanks, Jason. I noticed that the search result was not what I expected, so it would go beyond an UI issue. I will test again.
04:47
Kor
04:47 PM
I now see the id in the web admin!
05:02
Kor
05:02 PM
The search result is still not what I was expecting. Maybe something else is overruling.
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
05:10 PM
We fixed some related override issues in the latest RC build. Can we try upgrading you to this build?
Kor
Photo of md5-894e524356146cb346abbb1f595710f0
Kor
05:19 PM
Is this something that can be reversed easily?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
05:19 PM
Yeah, we can roll you back from our side
Kor
Photo of md5-894e524356146cb346abbb1f595710f0
Kor
05:20 PM
Ok, yes let's try it 🙂
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
05:20 PM
Ok I’ve queued it up. Should be done in about 5-7 minutes
Kor
Photo of md5-894e524356146cb346abbb1f595710f0
Kor
05:21 PM
Woohoo: “Configuration Change is in progress...” 😀

1

05:25
Kor
05:25 PM
Jason it now works as expected! Fantastic.
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
05:26 PM
Awesome!
Kor
Photo of md5-894e524356146cb346abbb1f595710f0
Kor
05:27 PM
By the way, is it case sensitive? So can I set an override for “TEL” (and not necesserali “tel”?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
05:28 PM
We fixed the case-sensitivity in the RC build you’re running IIRC
05:28
Jason
05:28 PM
Oh wait, that’s different
05:28
Jason
05:28 PM
all searches are case insensitive, including overrides
05:28
Jason
05:28 PM
So this is not possible to do:

&gt; I set an override for “TEL” (and not necesserali “tel”?
Kor
Photo of md5-894e524356146cb346abbb1f595710f0
Kor
05:29 PM
Ok, no problem.
06:42
Kor
06:42 PM
Is it possible to delete all overrides at once? (Instead of a specific one, as described here: https://typesense.org/docs/0.24.1/api/curation.html#delete-an-override )?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
06:43 PM
No unfortunately. You can only delete overrides one at a time.

You could write a quick snippet to read all overrides and then send delete API calls one at a time to do this programatically
Kor
Photo of md5-894e524356146cb346abbb1f595710f0
Kor
06:43 PM
Thanks, will do that.
06:52
Kor
06:52 PM
For future reference. This works for me. Thanks, ChatGPT:

BEGIN CHATGPT

#!/bin/bash

# Get all overrides
OVERRIDES=$(curl -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" "<http://localhost:8108/collections/companies/overrides>")

# Extract just the names from the overrides
OVERRIDE_NAMES=$(echo $OVERRIDES | jq -r '.overrides[] | .id')

# Loop over each override name and delete it
for OVERRIDE_NAME in $OVERRIDE_NAMES
do
curl "<http://localhost:8108/collections/companies/overrides/$OVERRIDE_NAME>" -X DELETE \
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}"
done


This script first sends a GET request to the Typesense API to retrieve all overrides. It then uses jq to extract just the IDs of each override into the OVERRIDE_NAMES variable. This is a space-separated list of all override names.

It then loops over each name in OVERRIDE_NAMES, sending a DELETE request to the Typesense API to delete that override.

Make sure to replace ${TYPESENSE_API_KEY} with your actual Typesense API key.

Please note that this will delete ALL overrides for the "companies" collection. If you have overrides that you don't want to delete, you will need to adjust the script to exclude those.

END CHATGPT

1

Typesense

Lightning-fast, open source search engine for everyone | Knowledge Base powered by Struct.AI

Indexed 3011 threads (79% resolved)

Join Our Community

Similar Threads

Troubleshooting 'Contains' Match and Override Issues in Typesense

John sought assistance due to a seemingly faulty override in Typesense that failed to bring up a specific entry. Jason suggested troubleshooting steps, including trying a smaller record set and considering a server upgrade. A bug with 'contains' match appeared identified but not conclusively resolved.

1

40
20mo

Resolving Issues with Infix and Prefix in Query Searches

Daren struggled with searches missing values in production. Jason and Kishore Nallan offered insights and created new features to help solve the problem, which was then tested and deployed by Daren.

2

38
5mo
Solved

Troubleshooting Issues with DocSearch Hits and Scraper Configuration

Rubai encountered issues with search result priorities and ellipsis. Jason helped debug the issue and suggested using different versions of typesense-docsearch.js, updating initialization parameters, and running the scraper on a Linux-based environment. The issues related to hits structure and scraper configuration were resolved.

7

131
8mo
Solved

Improving Search Hits in Typesense with User Feedback

Krish asked how to improve search hits based on user input. Kishore Nallan answered Typesense would allow manual curation and informed of upcoming updates.

13
11mo
Solved

Resolving Issues with Scoped API Keys in Typesense with Golang

Suvarna had problems with generating and using scoped API keys in Typesense with Golang. Several bugs misleading the user were found and fixed by Kishore Nallan.

6

158
28mo
Solved