Slackbot
11/29/2023, 12:11 AMJason Bosco
11/29/2023, 12:12 AMAnirudh Atodaria
11/29/2023, 12:12 AMAnirudh Atodaria
11/29/2023, 12:16 AM{
"id": "abc",
"items": [
{
"name": "example name - this is searechable",
"id": "xyz",
"nested_items": [
{
"name": "nested name not searchable"
},
{
"description": "name is optional"
}
]
},
{
"name": "example two",
"id": "jkl",
"nested_items": [
{
"name": "another random one"
},
]
}
]
}Anirudh Atodaria
11/29/2023, 12:16 AMAnirudh Atodaria
11/29/2023, 12:17 AMitems and nested_items with type=object[]Anirudh Atodaria
11/29/2023, 12:19 AMAnirudh Atodaria
11/29/2023, 12:22 AM{
"name": "items",
"type": "object[]"
},
{
"name": "items.nested_items",
"type": "object[]"
},
{
"facet": false,
"index": true,
"infix": false,
"locale": "",
"name": "items.nested_items.name",
"optional": true,
"sort": false,
"type": "string[]"
},
{
"facet": false,
"index": true,
"infix": false,
"locale": "",
"name": "items.name",
"optional": true,
"sort": false,
"type": "string[]"
},Anirudh Atodaria
11/29/2023, 12:23 AMitems and items.nested_items ?
Because I've not specified index=false on items or nested_items 🤔Jason Bosco
11/29/2023, 12:24 AMJason Bosco
11/29/2023, 12:25 AMitems or items.nested_items in the schema, just the last two fields should be sufficientAnirudh Atodaria
11/29/2023, 12:26 AMitems.nested_items.name )Jason Bosco
11/29/2023, 12:27 AMJason Bosco
11/29/2023, 12:27 AMAnirudh Atodaria
11/29/2023, 12:27 AMAnirudh Atodaria
11/29/2023, 12:43 AMexport TYPESENSE_API_KEY=xyz
curl "http://localhost:8108/debug" \
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}"
curl --location "http://localhost:8108/collections" \
--header "Content-Type: application/json" \
--header "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
--data '{
"enable_nested_fields": true,
"fields": [
{
"facet": false,
"index": true,
"infix": false,
"locale": "",
"name": "items.name",
"optional": true,
"sort": false,
"type": "string[]"
},
{
"facet": false,
"index": true,
"infix": false,
"locale": "",
"name": "items.description",
"optional": true,
"sort": false,
"type": "string[]"
},
{
"facet": false,
"index": true,
"infix": false,
"locale": "",
"name": "items.nested_items.name",
"optional": true,
"sort": false,
"type": "string[]"
}
],
"name": "test"
}'
curl --location 'http://localhost:8108/collections/test/documents?action=upsert' \
--header "Content-Type: application/json" \
--header "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
--data '{
"id": "7aae6a64-1dd0-4fd5-a6aa-f2807e804222",
"items": [
{
"description": "random description.",
"id": "d568961d-d555-4d22-b905-7543016ca695",
"name": "pirates",
"nested_items": [
{
"isAvailable": true
},
{
"isAvailable": true
},
{
"isAvailable": true,
"name": "one piece"
},
{
"description": "nested description here",
"isAvailable": true,
"name": "naruto"
},
{
"description": "description again", "isAvailable": true,
"name": "dragon ball"
}
]
},
{
"description": "random description.",
"id": "e568961d-d555-4d22-b905-7543016ca699",
"name": "super nova",
"nested_items": [
{
"isAvailable": true
},
{
"isAvailable": true
},
{
"isAvailable": true,
"name": "star wars"
},
{
"description": "nested description here",
"isAvailable": true,
"name": "pokemon"
},
{
"description": "description again",
"isAvailable": true,
"name": "ben 10"
}
]
}
]
}'
curl --location 'http://localhost:8108/collections/test/documents/search?q=naruto&query_by=items.name%2Citems.nested_items.name' \
--header "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}"Anirudh Atodaria
11/29/2023, 12:44 AMAnirudh Atodaria
11/29/2023, 12:44 AMcurl - if you replace naruto with pirates it'll return result but for naruto I don't get any results.Jason Bosco
11/29/2023, 12:51 AMAnirudh Atodaria
11/29/2023, 12:52 AMAnirudh Atodaria
11/29/2023, 1:05 AMKishore Nallan
12/01/2023, 7:47 AM0.25.2.rc11