#community-help

Troubleshooting Typesense 400 Error with Null Fields

TLDR sonu was encountering a 400 error due to null fields during Typesense indexing. Jason suggested upgrading to a recent version, removing null fields, and marking potentially null fields as optional: true. gab shared a similar issue and workaround.

Powered by Struct AI
26
31mo
Solved
Join the chat
Jul 09, 2021 (31 months ago)
sonu
Photo of md5-6ade4a341436f96c87480052a1584bf3
sonu
06:07 PM
i'm getting code 400 error from typesense while indexing ...because some of my fields some time returns null ....what should i do, i set them as string in typesense schema but some of are saved as null in db
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
06:07 PM
We addressed this in a recent RC build. What version of Typesense are you running?
sonu
Photo of md5-6ade4a341436f96c87480052a1584bf3
sonu
06:10 PM
0.12.1
06:10
sonu
06:10 PM
should i upgrade
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
06:12 PM
Oh yes! 0.21.0.rc24 is the latest version
06:13
Jason
06:13 PM
The workaround for previous versions is to remove null fields from the document fully
sonu
Photo of md5-6ade4a341436f96c87480052a1584bf3
sonu
06:35 PM
btw ..sorry but how do i install that rc version .....i tried this method i found ....didn't work 😅
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
06:40 PM
Oh I was talking about Typesense Server version. Those instructions are for typesense-js
06:41
Jason
06:41 PM
Are you self hosting or using Typesense Cloud?
sonu
Photo of md5-6ade4a341436f96c87480052a1584bf3
sonu
06:41 PM
i'm using docker ...as in self hosting
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
06:42 PM
What's the docker command you're using to start Typesense?
sonu
Photo of md5-6ade4a341436f96c87480052a1584bf3
sonu
06:43 PM
docker run -i -p 8108:8108 -v /tmp/typesense-data/:/data -v /tmp/typesense-logs/:/logs  typesense/typesense:0.20.0 --data-dir /data  --log-dir /logs  --api-key=xyz --listen-port 8108 --enable-cors
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
06:44 PM
> typesense/typesense:0.20.0
You want to change that to typesense/typesense:0.21.0.rc24
06:44
Jason
06:44 PM
and re-run that command
sonu
Photo of md5-6ade4a341436f96c87480052a1584bf3
sonu
06:45 PM
ohh ....silly me
07:17
sonu
07:17 PM
its the same even after using 0.21.0.rc24 ...gives 400error and says error: 'Field skill must be a string.',
07:18
sonu
07:18 PM
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
07:21 PM
Could you share the schema and a sample document (JSON) that failed?
sonu
Photo of md5-6ade4a341436f96c87480052a1584bf3
sonu
07:27 PM
yes sure
07:28
sonu
07:28 PM
rating is null for this one ....but in schema i set it as int32
gab
Photo of md5-8be2a24edf7a95c9c74abce4b1130c3e
gab
08:01 PM
I have the same issue. For now I have replaced my null values with undefined values. Also I have set as optional the field that can be nullish.
sonu
Photo of md5-6ade4a341436f96c87480052a1584bf3
sonu
08:07 PM
gab so set as undefined and optional ...does it affect your searching with typesense
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
08:07 PM
Oh you want to set fields that can be null as optional: true in the collection schema
sonu
Photo of md5-6ade4a341436f96c87480052a1584bf3
sonu
08:08 PM
ohh thanks Jason
gab
Photo of md5-8be2a24edf7a95c9c74abce4b1130c3e
gab
08:32 PM
I mean if I try to index a null value with a field that has (optional:true) it will give me an error 400. Is that intended behavior?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
10:12 PM
That used to be the case with v0.20.0. We've fixed that case in the most recent RC build: v0.21.0.rc24

Typesense

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

Indexed 3005 threads (79% resolved)

Join Our Community

Similar Threads

Issues with Schema Creation and Nested Fields

Sean encountered a problem with schema creation involving auto nested fields. Kishore Nallan suggested checking the API response for errors and adding problematic fields to the schema as optional. Sean confirmed the advice.

1

9
2mo
Solved

Troubleshooting Typesense Filter_by Parameter Issue

Sagar had trouble with the filter_by parameter in Typesense. Kishore Nallan identified issue related to indexing, which resolved part of the issue. Guidance was given for handling null values.

2

21
4mo
Solved

Troubleshooting 400 Error When Upgrading Typesense Firestore Extension

Orion experienced a `400` error after updating the Typesense Firestore extension, causing issues with cloud functions. They traced the issue back to a data type conflict in their Typesense collection schema after updating. With help from Jason and Kishore Nallan, they resolved the issue by recreating the collection.

5

96
14mo
Solved

Cold Start Problem with Dynamic Collections

Adrian reported cold start issues with dynamic collections. Jason suggested using wildcard `*` for query_by parameters, upgrading to `0.25.0.rc34`, and clarified conventions. Adrian's issues were resolved but they reported a limitation that will potentially be addressed.

6

39
6mo
Solved

Querying with Typesense-Js and Handling Null Values

michtio was querying using typesense-js and receiving fewer results than expected. Kishore Nallan suggested using different query parameters. Further discussion led to the handling of 'null' values and filtering syntax in the search queries. The thread ended with Jason offering migration support from Algolia to Typesense.

4

39
17mo
Solved