Cant merge the objects while upserting a document in specific index

I have index called "channel", first document has attribute "Members" and its type is list.

[{'_id': 'everyone', 'Name': 'Everyone', 'Type': 'Group', '_created_at': datetime.datetime(2018, 8, 2, 10, 36, 3, 369000), '_created_by': 'Us_d7b076f0963f11e8b5060242ac120015'},
{'Name': 'Prasanna', 'Type': 'User', '_id': 'Us_088af4a2965011e8b5060242ac120015', '_created_by': {'_id': 'Us_796d0ff69a0c11e8a7db0242ac12000a'}, '_created_at': datetime.datetime(2018, 8, 13, 11, 58, 4, 863000)}]

I have Members._created by will be dict or string. How can i store the data?

Error : "type":"illegal_argument_exception","reason":"Can't merge a non object mapping [Members._created_by] with an object mapping [Members._created_by]"

If you want to index this data, it has to be either one or the other as every field must have a single mapping within an index.

Could you please explain in detail?

Each field, e.g. _created_by, must have a single mapping within an index. You can therefore not have a field that can be either a string or an object. The only way you might be able to actually store it I believe is if you make it non-searchable. If you want to be able to search on this field you will therefore need to change the structure of your document.

Is there any link to how to create single mapping for field?

Have a look at the docs. This however requires that you change the document so that _created_by always is of one type (string or object).

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.