#community-help

CouchDB Document Indexing Issue

TLDR James struggled to index documents from CouchDB, resulting in errors. Kishore Nallan advised checking field definitions and the document's nature. Jason suggested missing "await" statements might cause issues.

Powered by Struct AI
Feb 02, 2022 (19 months ago)
James
Photo of md5-d506a013dfd4f2398dde554c30ffbdde
James
11:05 AM
Hello guys, So I'm getting the doc from my couchdb but the when I try to index if it my collection is doesn't work, does anyone know the cause of this issue?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
11:07 AM
Can you please tell me what error you are getting?
James
Photo of md5-d506a013dfd4f2398dde554c30ffbdde
James
11:29 AM
but x_top is there in the document, here's a gist to the code https://gist.github.com/jamessandy/b69d85a3300a6c1465ae5d70901198d6
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
11:31 AM
The collection schema defines a 'default_sorting_field': 'x_top'

If you define a default sorting field, that value should always be present in the document. The document you tried to index didn't have this field.
James
Photo of md5-d506a013dfd4f2398dde554c30ffbdde
James
11:37 AM
it does have
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
11:39 AM
Can you please try inserting one document outside separately? I'm pretty sure that one of the document is not having that field. You can try catching that exception and printing the value of the document.
James
Photo of md5-d506a013dfd4f2398dde554c30ffbdde
James
11:43 AM
verified?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
11:44 AM
I don't follow you
James
Photo of md5-d506a013dfd4f2398dde554c30ffbdde
James
11:49 AM
these are the values of the doc
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
11:51 AM
To unblock, remove the default_sorting_field configuration and see if it works.
James
Photo of md5-d506a013dfd4f2398dde554c30ffbdde
James
11:56 AM
it throws a new error
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
11:57 AM
Then there is something is certainly wrong in the document you are passing into Typesense, Please look carefully.
James
Photo of md5-d506a013dfd4f2398dde554c30ffbdde
James
12:02 PM
this is the entire document, can't seem to see anything wrong
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
12:05 PM
Can you please update this gist(https://gist.github.com/jamessandy/b69d85a3300a6c1465ae5d70901198d6) with that data example? I can then try running it.
James
Photo of md5-d506a013dfd4f2398dde554c30ffbdde
James
12:08 PM
I'm getting the data from my couchdb database
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
04:40 PM
James On a side note, it looks like Lines 121 and 126 are missing "await"
04:42
Jason
04:42 PM
Also, doesn't Line 4 need an await or callback of sorts? I'd imagine .get is async, when getting data from couchdb
04:44
Jason
04:44 PM
Essentially, you want to make sure that "doc" is an actual JS object when you console.log it just before sending it to Typesense