Shaun Byrnes
08/08/2023, 5:45 AMv0.26.0.rc11
Shaun Byrnes
08/08/2023, 5:46 AMfood
collection
{
"fields": [
{
"name": "foodBrandId",
"drop": true
},
{
"name": "foodBrandId",
"type": "string",
"optional": true,
"facet": false,
"sort": false,
"reference": "foodBrands.id"
}
]
}
Which it said was saved successfully, but I don't think the web UI knows how to show it yet, as that field disappears from the list of the schema when this change was applied (still seems to be found on the actual data).
Trying to make subsequent changes shows: "Error: e: Request failed with HTTP code 400 | Server said: Field foodBrandId
is not part of collection schema." so seems like all it ended up doing was dropping the field (I just added it back to schema).
Furthermore in the sole example given, can we do it this direction for the reference instead to accomplish the same thing:
Schema of Products
collection:
{
"name": "Products",
"fields": [
{
"name": "product_id",
"type": "string",
"reference": "CustomerProductPrices.product_id"
},
{
"name": "product_name",
"type": "string"
},
{
"name": "product_description",
"type": "string"
}
]
}
CustomerProductPrices collection’s schema would store the reference to the product and its associated price:
{
"name": "CustomerProductPrices",
"fields": [
{
"name": "customer_id",
"type": "string"
},
{
"name": "product_id",
"type": "string"
},
{
"name": "product_price",
"type": "float"
}
]
}
Or that wont work?
As when I tried to add the reference in my case about, I get this when trying to query:
"RequestMalformed: Request failed with HTTP code 400 | Server said: Failed to apply reference filter on foodBrands
collection: Could not find any field in foodBrands
referencing the collection food
."
However, I can't add the reference in the foodBrands
needs to be foods, as many foods could ref/share the same brand, so it needs to be food.foodBrandId
pointing to foodBrands.id
[12:26 PM] My query as follows: "filter_by": "$foodBrands(id:=foodBrandId)"
Kishore Nallan
08/08/2023, 5:47 AMHarpreet Sangar
08/08/2023, 6:27 AMreference
yet so you'll have to re-index the data. Regarding the Products
collection having the reference field, it won't work since we would be searching for products.
If I understood your problem correctly, you have food
and foodBrands
collections and you would want to search on food
collection and filter by specific foodBrands
?Shaun Byrnes
08/08/2023, 6:29 AMHarpreet Sangar
08/08/2023, 6:29 AMShaun Byrnes
08/08/2023, 6:30 AMreference
property and not have to delete everything ?Harpreet Sangar
08/08/2023, 6:31 AMShaun Byrnes
08/08/2023, 6:32 AMIf I understood your problem correctly, you have food and foodBrands collections and you would want to search on food collection and filter by specific foodBrands?
Yes we have both collections. Both do get searched and currently food
can filter by foodBrandId
already. We want to add the reference to foodBrands
so that when a food is returned (in any way) we can also grab the foodBrands.name
for example from the other collection (currently food just has the foreign key).Harpreet Sangar
08/08/2023, 7:09 AMShaun Byrnes
08/08/2023, 7:09 AMShaun Byrnes
08/08/2023, 11:22 PMHarpreet Sangar
08/09/2023, 6:13 AMShaun Byrnes
08/09/2023, 6:13 AMShaun Byrnes
08/09/2023, 6:14 AMShaun Byrnes
08/14/2023, 8:05 AMHarpreet Sangar
08/14/2023, 8:10 AMShaun Byrnes
08/14/2023, 8:10 AMShaun Byrnes
08/14/2023, 8:10 AMHarpreet Sangar
08/17/2023, 5:45 AMWe want to add the reference toThis should work by addingso that when a food is returned (in any way) we can also grab thefoodBrands
for example from the other collection (currently food just has the foreign key).foodBrands.name
include_fields: $foodBrands(name)
when searching on food
collection.
https://github.com/typesense/typesense/pull/1156Kishore Nallan
08/17/2023, 5:46 AMShaun Byrnes
08/17/2023, 5:47 AMShaun Byrnes
03/28/2024, 4:41 AMKishore Nallan
03/28/2024, 5:07 AM0.26.0.rc68
which contains a syntax change for join. The nest/merge of fields syntax is now through the strategy
keyword:
"include_fields": "$authors(*, strategy: merge)"
Shaun Byrnes
03/28/2024, 5:15 AMShaun Byrnes
03/28/2024, 5:15 AMKishore Nallan
03/28/2024, 5:17 AM0.26.0.rc67
Kishore Nallan
03/28/2024, 5:17 AMShaun Byrnes
03/28/2024, 6:00 AMShaun Byrnes
03/28/2024, 6:00 AMShaun Byrnes
03/28/2024, 6:02 AMstrategy
after last comma yea? That way $coll(id, strategy, strategy: nest)
would work still correct ?Shaun Byrnes
03/28/2024, 6:02 AMstrategy
Harpreet Sangar
03/28/2024, 6:05 AMstrategy:
is what the parser looks for. So having strategy
porp would not interfere.Shaun Byrnes
03/28/2024, 6:05 AMShaun Byrnes
03/28/2024, 6:05 AMstrategy:nest
as in no spaceShaun Byrnes
03/28/2024, 6:06 AMstrategy\:\s*(nest|merge)
Shaun Byrnes
03/28/2024, 6:06 AM