This message was deleted.
# community-help
s
This message was deleted.
n
@Jason Bosco @Kishore Nallan I have a demo coming up soon where I am hoping to show this feature. Any chance you can let me know how to find the doc 996 so that I can fix any referencing issue? Thanks!
j
> doc 996 when custom id is specified in our documents Not sure I understand this... but if you specify an
id
field in the docs, this is what that ID refers to. If you don't set one, it is automatically generated by Typesense. If you didn't set an
id
field explicitly, you could do something like
GET /collections/name/documents/id
(where id would be 996 in your case) to get the document that that ID refers to
Is there a way for me to ignore a missing reference?
There is no way to do this at the moment
n
Thanks Jason. I am still not able to find the document. In the next sync, I got error for doc 577 and I can't find it
Also in my case
id
looks like this:-
j
Hmm is that last screenshot from the
categories
collection?
n
No that is from items collection
I am getting the same error in the other collection too
j
Could you share your full collection schema for both items and categories?
n
For items, the schema is quite big. Should I share the join + id part?
j
Yeah just that part would be sufficient
n
Copy code
const itemsCollectionSchemaFields: CollectionCreateSchema["fields"] = [
	{ name: "id", type: "string", index: true, optional: false, sort: true, infix: true, facet: true },
	{ name: "_id", type: "string", index: true, optional: false, sort: false, infix: false },
	{ name: "commodityId", type: "string", index: true, optional: true, sort: false, infix: false, facet: true, reference: "commodities.id" }
];
Copy code
const commoditiesCollectionCreateSchema: CollectionCreateSchema["fields"] = [
	{ name: "id", type: "string", index: true, optional: false, sort: false, infix: false }, // commodityId
	{ name: "description", type: "string", index: true, optional: false, sort: true, infix: false },
	{ name: "active", type: "bool", index: true, optional: false, sort: false, infix: false }, // useful for deleting all documents
];
j
In the search query you shared above you have
$categories
... could you share that collection's schema?
n
I had changed that query for clarity. Actually the collection name is commodities
j
Could you put together a minimal but complete example using curl requests like this that replicates the issue?
n
Do you think referencing id is the issue? Should I just use another field in the commodities collection?
I will prepare a repro but just wanted to take a shot before a meeting coming up soon
j
Yeah that could be an issue, since
id
is a special field... If that's the issue, we can try addressing that
Worth a shot, but I can't tell for sure if that's the issue yet
n
Ok I will check. Thanks!
@Jason Bosco It still didn't work even though I changed the field to
commodityId
@Jason Bosco Is there no way for me to retrieve this document? It would help me create the repro if I knew what data is causing the failure. Thanks!
j
Hmmm, I'm not sure... Could you try replicating the issue with a similar schema (at least a subset that includes the joins) and similar documents to what you have?
CC: @Harpreet Sangar
n
@Harpreet Sangar Is there some way for me to debug this?
h
Sorry, I didn't get the earlier ping. Looking into this now.
👍 1
This issue is because the reference field is optional
Copy code
{ name: "commodityId", type: "string", index: true, optional: true, sort: false, infix: false, facet: true, reference: "commodities.id" }
and when we try to compute the sort score of a document that doesn't have a reference on the basis of
$commodities(description:asc)
, it returns this error.
n
Thanks Harpreet. I will fix this and try again
@Harpreet Sangar To make upsert work with import, do I need to specify my own id field? I had removed id from schema and put
commodityId
instead. But I am concerned that next import would duplicate the values
h
Since you didn't have id field in the docs, it would indeed duplicate the values.
You'll have to match the id that typesense generated for your doc to update a particular doc.
n
@Harpreet Sangar If both the collections have
description
field, can there be an issue with sorting by both the props? In this case I am trying to sort by commodity description and then item description. However items are not getting sorted even though commodities are
h
I don't think having common field name would cause such issue.
Can you share an example?
n
See this for e.g.
Item name "Coffee" should have come before "Hot Choc"
h
Okay I'll try to reproduce this.
n
Thanks @Harpreet Sangar. Is there any workaround you can suggest?
h
Cannot think of anything at the moment. I'll have to debug this to understand what's happening.
n
Ok we have a production app where I am hoping to deploy this change due to it being escalated quite a bit. Please let me know once you have debugged this. I feel otherwise the typesense build seems quite stable
@Harpreet Sangar I checked that this sorting is broken in general for 2 fields with first one being join field. Same name is not the issue
👍 1
h
Hey @Nikhil Agarwal I've fixed the sorting bug. It will be available in the next rc build.
n
Thanks @Harpreet Sangar! Looking forward to trying that out