#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
smile2
25
2mo
Solved
Join the chat
Jul 26, 2023 (2 months ago)
Kor
Photo of md5-e18fd6bf1ed8f3adba05f7061edef1e1
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 (<a href="https://typesense.org/docs/0.24.1/api/curation.html#create-or-update-an-override" target="_blank">https://typesense.org/docs/0.24.1/api/curation.html#create-or-update-an-override</a>) but I have the feeling I am not understanding how it works.<br><br>I managed to import an override via curl, and I can see it show up in the Typesense's admin (in the browser).<br>This is the object I import:<br><code>&#x27;{</code><br>  <code>&quot;rule&quot;: {</code><br>    <code>&quot;query&quot;: &quot;revoke digital certificates and manage public-key encryption&quot;,</code><br>    <code>&quot;match&quot;: &quot;exact&quot;</code><br>  <code>},</code><br>  <code>&quot;includes&quot;: [</code><br>    <code>{</code><br>      <code>&quot;id&quot;: &quot;30642&quot;,</code><br>      <code>&quot;position&quot;: 1</code><br>    <code>}</code><br>  <code>]</code><br><code>}&#x27;</code><br><br>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-e18fd6bf1ed8f3adba05f7061edef1e1
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-e18fd6bf1ed8f3adba05f7061edef1e1
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-e18fd6bf1ed8f3adba05f7061edef1e1
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-e18fd6bf1ed8f3adba05f7061edef1e1
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-e18fd6bf1ed8f3adba05f7061edef1e1
Kor
05:21 PM
Woohoo: “Configuration Change is in progress...” 😀
smile1
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-e18fd6bf1ed8f3adba05f7061edef1e1
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:

> I set an override for “TEL” (and not necesserali “tel”?
Kor
Photo of md5-e18fd6bf1ed8f3adba05f7061edef1e1
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-e18fd6bf1ed8f3adba05f7061edef1e1
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
smile1