Issue with Join Operation in `CustomerProductPrices` Collection
TLDR Nikhil had concerns about adding product prices before the corresponding product and reported a crash when using a filter clause. Harpreet provided a workaround for fetching related products and also suggested a reason for the need of product presence enforcement. The crash could not be reproduced at Harpreet's end.
1
Aug 13, 2023 (1 month ago)
Nikhil
12:28 PMCustomerProductPrices
collection, would it fetch the product automatically or would that require a filter clause as well? Currently the examples seem to be mainly about fetching from Products
collection which doesn't have the reference field.Nikhil
05:10 PMNikhil
06:46 PM"filter_by":"$ItemCommon(itemNumber:!='')",
Aug 14, 2023 (1 month ago)
Harpreet
05:09 AMCustomerProductPrices
soon. It won't require any filter clause but you'll have to specify include_fields: $Products(*)
to get all the fields of related product or specific field names.Harpreet
05:34 AM>
When a document containing a reference field is created, we lookup the referenced collection and store a reference in
foo_sequence_id
field. That's the reason for enforcing the presence of product.Harpreet
05:36 AMNikhil
06:24 AM// Collection 1 - item_master
{
"name": "item_master",
"enable_nested_fields": true,
"fields": [
{
"name": "id",
"type": "string",
"index": true,
"optional": false,
"sort": true,
"infix": true,
"facet": true
},
{
"name": "attrId",
"type": "string",
"index": true,
"optional": true,
"infix": true,
"facet": true
},
{
"name": "itemNumber",
"type": "string",
"index": true,
"optional": true,
"sort": true,
"infix": false,
"reference": "items.itemNumber"
},
{
"name": "name",
"type": "string",
"index": true,
"optional": false
}
]
}
// 2nd collection "items"
{
"name": "items",
"enable_nested_fields": true,
"fields": [
{
"name": "itemNumber",
"type": "string",
"index": true,
"optional": true,
"sort": true,
"infix": false
},
{"name": "notes", "type": "string"},
{ "name": "guideType", "type": "int32", "index": true, "optional": false, "sort": false , "infix": false}
]
}
Nikhil
06:24 AMNikhil
06:26 AM{
"itemNumber": "123456",
"notes": "TEst Item 1",
"guideType": 1
}
And then to item_master
{
"_id": "abc",
"itemNumber": "123456",
"name": "Test Item 1"
}
Harpreet On a side note, please also note this is an example of why I need
item_master
to have an item even though items
collection doesn't have it (given how current join works which can change)Nikhil
06:26 AMNikhil
08:17 AMHarpreet
08:21 AM1
Aug 16, 2023 (1 month ago)
Nikhil
01:19 PMAug 17, 2023 (1 month ago)
Harpreet
05:37 AMcurl -k "" -X POST -H "Content-Type: application/json" -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" -d '{
"name": "item_master",
"enable_nested_fields": true,
"fields": [
{
"name": "id",
"type": "string",
"index": true,
"optional": false,
"sort": true,
"infix": true,
"facet": true
},
{
"name": "attrId",
"type": "string",
"index": true,
"optional": true,
"infix": true,
"facet": true
},
{
"name": "itemNumber",
"type": "string",
"index": true,
"optional": true,
"sort": true,
"infix": false,
"reference": "items.itemNumber"
},
{
"name": "name",
"type": "string",
"index": true,
"optional": false
}
]
}'
curl -k "" -X POST -H "Content-Type: application/json" -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" -d '{
"name": "items",
"enable_nested_fields": true,
"fields": [
{
"name": "itemNumber",
"type": "string",
"index": true,
"optional": true,
"sort": true,
"infix": false
},
{"name": "notes", "type": "string"},
{ "name": "guideType", "type": "int32", "index": true, "optional": false, "sort": false , "infix": false}
]
}'
curl ""
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}"
-H "Content-Type: text/plain"
-X POST
-d '{"itemNumber": "123456", "notes": "TEst Item 1", "guideType": 1}'
curl ""
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}"
-H "Content-Type: text/plain"
-X POST
-d '{"_id": "abc", "itemNumber": "123456", "name": "Test Item 1"}'
curl -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" "\
&filter_by=$item_master(itemNumber:!='')"
Harpreet
05:38 AM{
"facet_counts": [],
"found": 1,
"hits": [
{
"document": {
"guideType": 1,
"id": "0",
"itemNumber": "123456",
"notes": "TEst Item 1"
},
"highlight": {},
"highlights": []
}
],
"out_of": 1,
"page": 1,
"request_params": {
"collection_name": "items",
"per_page": 10,
"q": "*"
},
"search_cutoff": false,
"search_time_ms": 0
}
Nikhil
03:06 PMHarpreet
03:56 PMTypesense
Indexed 2776 threads (79% resolved)
Similar Threads
Resolving Issues with Reference Field in v0.26.0.rc11
Shaun reported problems applying the reference field in `v0.26.0.rc11`. The issue made the tested field disappear from UI, and an attempt to fix it resulted in an error. Harpreet suggested re-indexing data and promised to consider improving the feature in future updates. Harpreet is currently working on a related feature - sorting by reference field.
Fixing Multiple Document Retrieval in Typesense
Phil needed an efficient way to retrieve multiple documents by id. Kishore Nallan proposed a solution available in a pre-release build. After some bug fixing regarding id matching by Jason and Kishore Nallan, Phil successfully tested the solution.
Discussions on Typesense, Collections, and Dynamic Fields
Tugay shares plans to use Typesense for their SaaS platform and asks about collection sizes and sharding. Jason clarifies Typesense's capabilities and shares a beta feature. They discuss using unique collections per customer and new improvements. Kishore Nallan and Gabe comment on threading and data protection respectively.
Resolving Special Character Search Errors
suraj had issues searching for data containing special characters. Kishore Nallan resolved the issue by advising suraj to remove the parameters for 'preSegmentedQuery' and 'tokenSeparators'.
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.