#community-help

Issue with Null Values in TypeSense Document Import

TLDR Peter is having issues with document import erroring due to null values. Kishore Nallan tries to help and advises several troubleshooting steps and potential fixes. The issue remains unresolved.

Powered by Struct AI
thinking_face1
Feb 15, 2022 (19 months ago)
Peter
Photo of md5-6d0a219b26742f0482bc350d65c854c9
Peter
02:49 AM
Hello all. New to TypeSense, still figuring out the API. Currently having an issue with documents import erroring out due to Field 'cpvIndex' must be an int32. This field (and others) can be null. My schema looks as follows:
fields: [
  {name: '.*', type: 'auto', optional: true},
  {
     name: 'cpvIndex',
     type: 'int32',
     facet: false,
     optional: true, // <-- should allow null vals?
  },
  ...
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
02:50 AM
👋 does this error happen when you send a null value as an integer?
02:51
Kishore Nallan
02:51 AM
This might be a bug, I'll look. For now, you could remove the null values from the object before sending to Typesense.
Peter
Photo of md5-6d0a219b26742f0482bc350d65c854c9
Peter
02:52 AM
error seems to happen when the value for this field is null
02:55
Peter
02:55 AM
when i remove the null key vals from the document, i'm getting Field cpvIndex has been declared in the schema, but is not found in the document.
02:56
Peter
02:56 AM
can't really set them to 0 since this would be incorrect data for us 😞
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
02:58 AM
No I mean just remove the key from the json dictionary.
02:58
Kishore Nallan
02:58 AM
Oh got it, let me look
Peter
Photo of md5-6d0a219b26742f0482bc350d65c854c9
Peter
02:58 AM
thanks!
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
02:59 AM
May I know what version of Typesense you are using?
Peter
Photo of md5-6d0a219b26742f0482bc350d65c854c9
Peter
03:00 AM
Typesense v0.23.0.rc21 (Jason bumped me up, to allow string-based sort)
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
03:17 AM
Peter I'm able to send null values for an integer, see this quick example that works for me locally: https://gist.github.com/kishorenc/916f2988e39f48dc51893e58011c7c72
thinking_face1
03:20
Kishore Nallan
03:20 AM
On your cluster, can you hit the /collections end-point and check the exact schema that Typesense has stored for this collection?
Peter
Photo of md5-6d0a219b26742f0482bc350d65c854c9
Peter
03:23 AM
yes, it looks correct
      "facet": false,
      "index": true,
      "name": "cpvIndex",
      "optional": true,
      "type": "int32"
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
03:23 AM
Did you try indexing a single document from the curl like in the example above just to be sure?
Peter
Photo of md5-6d0a219b26742f0482bc350d65c854c9
Peter
03:24 AM
not yet, will try in a bit
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
06:09 AM
Ok, let me know once you have had a chance to try that out and I will be happy to debug further based on that.