#community-help

Editing and Updating Schema in Typesense Cloud

TLDR Loic sought help editing their Typesense Cloud Schema and adding search parameters. Jason guided them on how to drop a field and add another parameter for searching.

Powered by Struct AI
+11
12
8mo
Solved
Join the chat
Jan 25, 2023 (8 months ago)
Loic
Photo of md5-3a88a602e4aba6a18b4a6c6985fcf08c
Loic
06:57 PM
Jason Hey, in typesense cloud I have this error message:
Does it mean that I have to delete the collection or can I edit the schema ? :/
Error: e: Request failed with HTTP code 400 | Server said: Field `priceRetail` is already part of the schema: To change this field, drop it first before adding it back to the schema.
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
06:58 PM
If you’re running 0.23.1, you can edit the schema in place: https://typesense.org/docs/0.23.1/api/collections.html#update-or-alter-a-collection
06:58
Jason
06:58 PM
On Typesense Cloud, if you’re running 0.23.1, you’ll find the option to “Change Schema” under the “Collection Settings” section
Loic
Photo of md5-3a88a602e4aba6a18b4a6c6985fcf08c
Loic
07:00 PM
I am on v0.23.1
I was already trying to do this modification through “Update Schema”
How do you drop a field?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
07:01 PM
{
  "fields":[
    {"name":"priceRetail", "drop": true}, // <== You'd need to add this
    {"name":"priceRetail", "type":"float"}
  ]
}
Loic
Photo of md5-3a88a602e4aba6a18b4a6c6985fcf08c
Loic
07:04 PM
Thanks Jason, I will try that
07:35
Loic
07:35 PM
Jason It is working thank you.
Other stupid question,
in:
07:35
Loic
07:35 PM
final searchParameters = {
  'q': 'stark',
  'query_by': 'company_name',
  'filter_by': 'num_employees:>100',
  'sort_by': 'num_employees:desc'
};

await client.collection('companies').documents.search(searchParameters);
07:36
Loic
07:36 PM
How do you add another search parameter in 'filter_by': 'num_employees:&gt;100' ?
07:36
Loic
07:36 PM
for example isShowingRetailPortal:=true
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
07:37 PM
'filter_by': 'num_employees:&gt;100 &amp;&amp; isShowingRetailPortal:=true
Loic
Photo of md5-3a88a602e4aba6a18b4a6c6985fcf08c
Loic
07:37 PM
thank you
+11