I want to search with the tag name and dish name.
I tried this but it did not work
<code>const data = await typesenseClient.collections("dishes_view").documents().search({
'q': 'tag1',
'query_by': '*',
"filter_by": "$dish_tags(id: *)",
"include_fields": "$tags(*) as as tagsData ,name"
})
console.log(JSON.stringify(data, null, 2));
</code>
<code>const data = await typesenseClient.collections("dishes_view").documents().search({
'q': 'tag1',
'query_by': '*',
"filter_by": "$dish_tags(id: *)",
"include_fields": "$tags(*) as as tagsData ,name"
})
console.log(JSON.stringify(data, null, 2));
</code>
const data = await typesenseClient.collections("dishes_view").documents().search({
'q': 'tag1',
'query_by': '*',
"filter_by": "$dish_tags(id: *)",
"include_fields": "$tags(*) as as tagsData ,name"
})
console.log(JSON.stringify(data, null, 2));
Is there any mistake in my search query or is typesense not providing a search in the join table?
If there is any mistake in my query please provide the correct search query. Is there any other to implement this functionality
This is my collection Schema
<code>const schema={
"name": "dishes",
"num_documents": 0,
"fields": [
{ "name": "id", "type": "string", "facet": false },
{ "name": "name", "type": "string", "facet": false },
{ "name": "unit", "type": "int32", "facet": false, "optional": true },
{ "name": "calories", "type": "int32", "facet": false, "optional": true },
{ "name": "price", "type": "int32", "facet": false },
{ "name": "is_active", "type": "bool", "facet": false },
{ "name": "size", "type": "int32", "facet": false, "optional": true },
],
"default_sorting_field": "created_at",
"enable_nested_fields": true
}
const schema = {
"name": "tags",
"num_documents": 0,
"fields": [
{ "name": "id", "type": "string", "facet": false },
{ "name": "name", "type": "string", "facet": false }
],
"enable_nested_fields": true}
const schema = {
"name": "dish_tags",
"num_documents": 0,
"fields": [
{ "name": "dish_id", "type": "string", "facet": false, "reference": "dishes_view.id" },
{ "name": "tags_id", "type": "string", "facet": false, "reference": "tags.id" }
],
"enable_nested_fields": true
}
</code>
<code>const schema={
"name": "dishes",
"num_documents": 0,
"fields": [
{ "name": "id", "type": "string", "facet": false },
{ "name": "name", "type": "string", "facet": false },
{ "name": "unit", "type": "int32", "facet": false, "optional": true },
{ "name": "calories", "type": "int32", "facet": false, "optional": true },
{ "name": "price", "type": "int32", "facet": false },
{ "name": "is_active", "type": "bool", "facet": false },
{ "name": "size", "type": "int32", "facet": false, "optional": true },
],
"default_sorting_field": "created_at",
"enable_nested_fields": true
}
const schema = {
"name": "tags",
"num_documents": 0,
"fields": [
{ "name": "id", "type": "string", "facet": false },
{ "name": "name", "type": "string", "facet": false }
],
"enable_nested_fields": true}
const schema = {
"name": "dish_tags",
"num_documents": 0,
"fields": [
{ "name": "dish_id", "type": "string", "facet": false, "reference": "dishes_view.id" },
{ "name": "tags_id", "type": "string", "facet": false, "reference": "tags.id" }
],
"enable_nested_fields": true
}
</code>
const schema={
"name": "dishes",
"num_documents": 0,
"fields": [
{ "name": "id", "type": "string", "facet": false },
{ "name": "name", "type": "string", "facet": false },
{ "name": "unit", "type": "int32", "facet": false, "optional": true },
{ "name": "calories", "type": "int32", "facet": false, "optional": true },
{ "name": "price", "type": "int32", "facet": false },
{ "name": "is_active", "type": "bool", "facet": false },
{ "name": "size", "type": "int32", "facet": false, "optional": true },
],
"default_sorting_field": "created_at",
"enable_nested_fields": true
}
const schema = {
"name": "tags",
"num_documents": 0,
"fields": [
{ "name": "id", "type": "string", "facet": false },
{ "name": "name", "type": "string", "facet": false }
],
"enable_nested_fields": true}
const schema = {
"name": "dish_tags",
"num_documents": 0,
"fields": [
{ "name": "dish_id", "type": "string", "facet": false, "reference": "dishes_view.id" },
{ "name": "tags_id", "type": "string", "facet": false, "reference": "tags.id" }
],
"enable_nested_fields": true
}
New contributor
Nisarg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1