Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to add data into a nested indexed field when optional flag is false in the schema #1656

Open
abiudmani opened this issue Apr 7, 2024 · 2 comments
Labels

Comments

@abiudmani
Copy link

Description

Not able to import/upsert a new document data in a collection with a nested indexed field when optional flag is set to false in the schema

Steps to reproduce

  1. Create a collection with nested fields (object or object[] which has a parent_name.child_name)
  2. The nested field should be set with index=true and optional=false (which are the default values)
  3. Try to create a document and it fails with reason that the specific field is indexed in the schema but the document doesn't have the data for the same (but the data was present)
    "error":"Field parent_name.child_name has been declared in the schema, but is not found in the document."
  4. This issue is faced on v26.0 version and the same is working fine on previous versions

On the version v26.0, tried changing the optional flag to true with still the index as true (which was not being allowed in the previous versions), then this issue is resolved. But this seems contrary, as with index enabled, the field is being set as optional if we enable the optional flag to true.

Expected Behavior

When a nested field is indexed and optional flag is set to false, it should work as expected.
This is working fine in the version v0.25.2

Actual Behavior

When a nested field is indexed and optional flag is set to false, cannot able to add a document.
This issue is seen in the version v26.0

Metadata

Typesense Version: v26.0

OS: Cloud

@kishorenc
Copy link
Member

@abiudmani

I just tried an example but it seems to work for me. See here: https://gist.github.com/kishorenc/6529cd9d48fc4be960dd158d43cc1f18

Can you post a similar example with exact schema and the document being inserted?

@abiudmani
Copy link
Author

Hi @kishorenc, Thanks for the response. I think, I got the issue now.

When you have declared the object, you have declared as follows,
{"name": "name", "type": "object"},
but when I declared the same for an array object, I declared as follows,
{"facet":false,"index":false,"infix":false,"locale":"","name":"oDS","optional":true,"sort":false,"stem":false,"type":"object[]"}

since the index is false and the optional field type as true, I'm facing this issue.
When we declare the object / object[] types, is the index type has to be set to true (i.e default value)?

The schema, document & error I faced are as follows:
Scheme:
"fields":[
{"facet":false,"index":false,"infix":false,"locale":"","name":"oDS","optional":true,"sort":false,"stem":false,"type":"object[]"},{"facet":true,"index":true,"infix":false,"locale":"","name":"oDS.delState","optional":false,"sort":false,"stem":false,"type":"string[]"},{"facet":false,"index":true,"infix":false,"locale":"","name":"oDS.delStateValue","optional":false,"sort":false,"stem":false,"type":"int32[]"}]

Document:
{"id":"1","oDS":[{"delState":"In Progress","delStateValue":1}]}

Error:
{"code":400,"document":"{"id":"1","oDS":[{"delState":"In Progress","delStateValue":1}]}","error":"Field oDS.delStateValue has been declared in the schema, but is not found in the document.","success":false}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants