#community-help

Issues with Field Types in Nested Schema

TLDR Emma reported an issue with nested field types showing incorrect behavior in both 0.25.0rc34 and rc54. Kishore Nallan asked them to create a Github issue to track the problem and also suggested setting a specific property for indexing Mandarin.

Powered by Struct AI
Aug 05, 2023 (4 months ago)
Emma
Photo of md5-01ff2c7cb764a071332074d6e85db0c5
Emma
01:31 AM
Seeing very weird behavior of nested fields in both 0.25.0rc34 and rc54, it seems to be confused on field types. With the following schema:
{
  "name": "anime:production@42069",
  "enable_nested_fields": true,
  "fields": [
    {
      "name": "titles",
      "type": "object"
    },
    {
      "name": "titles\\..*",
      "type": "string"
    },
    {
     "name": "start_date",
     "type": "object"
    },
    {
      "name": "start_date\\..*",
      "type": "int32",
      "facet": true,
      "optional": true
    }
  ]
}

I attempt to insert the following:
{
  "titles": {
    "zh-cn": "我的英雄学院"
  },
  "id": "420",
  "start_date": {
    "year": 2020,
    "month": 2,
    "day": 3
  }
}

And get the following error:
{
  "message": "Field `titles.zh-cn` must be an int32."
}

Even though I clearly defined titles\..* to be string :thinking_face:
01:35
Emma
01:35 AM
Perhaps notable is that removing the definitions for start_date and start_date\..* resolves it, even though they definitely do not match the field
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
01:41 AM
👋 That's a very odd issue. I'll take a look at this. Can you please create a Github issue just capturing the above example? Will be useful to track it. Thanks.
Emma
Photo of md5-01ff2c7cb764a071332074d6e85db0c5
Emma
01:41 AM
will do!
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
01:44 AM
Also, for indexing mandarin, you should set the locale property of the field to zh
Emma
Photo of md5-01ff2c7cb764a071332074d6e85db0c5
Emma
01:45 AM
Indeed, I do that too, I’ve got a bunch of field definitions for .*\.zh.* which define locales, but I reduced this testcase and happened to choose the mandarin field when doing so 😅 Still happens even with english, I’ll change that in the github issue
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
01:48 AM
Yes got it, this is unrelated to the type issue. Just wanted to make sure you were aware of the locale property. I will get back to you with what's happening here.
01:50
Emma
01:50 AM
I mention this in the issue, but I want to note here too: the start_date field alone is fine, it’s the start_date\..* field which breaks it
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
01:53 AM
👍
Emma
Photo of md5-01ff2c7cb764a071332074d6e85db0c5
Emma
03:12 AM
I’ve worked around this for now by just declaring the day month and year fields explicitly, thankfully that works for my use case 😅

Typesense

Lightning-fast, open source search engine for everyone | Knowledge Base powered by Struct.AI

Indexed 3015 threads (79% resolved)

Join Our Community

Similar Threads

Accessing Nested Objects Using `query_by` in Typesense

Emma wanted to query nested objects using `query_by`. Kishore Nallan suggested using `title.*` pattern and ensuring `enable_nested_fields` is set to true.

3

10
6mo

Trouble in Implementing Deeply Nested Search

Anirudh is struggling to implement a two-level nested search. Jason asked for some specific examples to study the issue. Anirudh provided some material, realizing that adding top fields helped but might over-index. Jason then suggested reporting this issue on GitHub.

2

21
3d

Resolving Multilingual Search Function in Typesense Software

Bill is having difficulty with multilingual search functionality in Typesense software. Developer Kishore Nallan suggested setting a language locale and provided a demo build. The build solution had some issues, and after multiple rounds of software updates and troubleshooting, the problem still persists.

2

89
25mo

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.

6

39
6mo

Issue with `included_fields` Command in Typesense

SamHendley encountered an issue with the `included_fields` command in Typesense versions 0.23.0 and 0.24.0.rc17. Jason helped identify it as a bug in the 0.24.X version, which was later addressed in release 0.24.0.rcn19.

16
14mo