-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Allow arrays and concrete values in flat object mapping types #8250
Comments
Hi, if I am not mistaken the JSON (as a "lightweight data-interchange format") should be represented in two basic forms (excerpt from https://www.json.org/json-en.html):
In other words it is either a hash-map like object This rules out all the other cases like: Currently the As for the second part of your question: Would it be possible to make it more general? Technically, it should be possible to wrap any non hash-map like object (yet still valid JSON value) into elemental hash-like object, for example:
But I am not sure if IMO such data transformation should happen in an Ingest pipeline (see Ingest API) which precedes the indexing operation. There are many Ingest processors that can help with this task (unfortunately OpenSearch docs about Ingest processors seem to be missing some processors, so I would point you to Elasticsearch 7.10 documentation about Ingest processors for now). In any case, you will need to get a bit creative when setting up such ingest job but I believe it can get you quite far. |
Wanted to note that I mentioned this issue in another issue: My suggestion is to at least support the "ignore_malformed" option for flat_object to allow the document to index, but ignore the field. |
@lukas-vlcek The JSON spec page you link very specifically defines the JSON grammar as:
So even though it is built on objects and arrays, JSON clearly permits simple values such as my examples above. |
When I don't have full control of values I'm going to be adding to OpenSearch I might want use the new flat object type to support whatever type we receive. This works for nested JSON objects such as:
{"desc":true}
However it fails with other valid JSON values such as:
["field1","field2"]
"desc"
-1
true
When trying to add a field of this type it fails even though these are valid JSON objects. With an array the error is
Or in the case of a concrete value:
object mapping for [_doc] tried to parse field [sort] as object, but got EOF, has a concrete value been provided to it?
Ideally, I'd like
flat_object
mappings to support all valid JSON types including arrays, strings, integers and booleans. If there are no plans to support these then the documentation may benefit from highlighting these limitations.The text was updated successfully, but these errors were encountered: