This message was deleted.
# community-help
s
This message was deleted.
j
Could you share one sample document?
a
yep I'm on it
Copy code
{
  "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"
        },
      ]
    }
  ]
}
this is made up - lmk if this does not help.
I'm experimenting RN - I'm trying to add
items
and
nested_items
with
type=object[]
Another approach I'm considering is to add flattened names at top level.
Seems like adding these worked -
Copy code
{
        "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[]"
    },
But I assume this indexes everything inside of
items
and
items.nested_items
? Because I've not specified
index=false
on
items
or
nested_items
🤔
j
The more generic field definition will supersede more specific ones. So if you want to only index a sub-field, you don't want to mention the top level fields
In this schema: https://typesense-community.slack.com/archives/C01P749MET0/p1701217353221239?thread_ts=1701216681.083179&cid=C01P749MET0 You shouldn't have to specify
items
or
items.nested_items
in the schema, just the last two fields should be sufficient
a
Hm, but with that setup (i.e. only having specific fields) - I'm not getting search results from the nested one - (i.e.
items.nested_items.name
)
j
Hmm, could you help replicate this issue using a set of curl commands like this: https://gist.github.com/jasonbosco/7c3432713216c378472f13e72246f46b#file-typesense-repro-steps-sh
and share those curl commands here?
a
Sure
Copy code
export 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}"
Does this help?
in the last search
curl
- if you replace
naruto
with
pirates
it'll return result but for
naruto
I don't get any results.
j
Yup, I'm able to replicate the issue. Mind copy-pasting the above curl commands into a GitHub issue so we can track it? Will take a closer look and keep you posted on the GitHub issue
a
Sure thing - I'll raise an issue.
🙏 1
Raised this issue - https://github.com/typesense/typesense/issues/1403 Lmk if there is anything I can help with. Thanks for taking a look 🙌
👍 1
k
👋 We've a potential fix on this build:
0.25.2.rc11
❤️ 1