Open JavierDelgadoFernandez opened 8 years ago
Ping.
Ping.
CC @nharraud @inveniosoftware/triagers can be used to alert people
@JavierDelgadoFernandez you can use definitions
:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"definitions": {
"owner": {
"type": "object",
"properties": {
"car": {
"$ref": "#/definitions/car"
}
},
"car": {
"type": "object",
"properties": {
"owner": {
"$ref": "#/definitions/owner"
}
}
},
if you want only one schema:
"type": "object",
"oneOf": [
{"$ref": "#/definitions/owner"},
{"$ref": "#/definitions/car"}
]
}
otherwise create new schemas with references:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"$ref": "base.json#/definitions/owner or car"
}
@jirikuncar I think the issue is that domapping works in a recursive manner.
But the problem might be more generic. I don't think that elasticsearch mappings provides any easy way to support recursive mappings. At least parent-child relationships cannot be used for that, see elastic/elasticsearch#8100 and elastic/elasticsearch#11432.
It might be possible with dynamic templates. @JavierDelgadoFernandez could you check if you can use it to create by hand a mapping matching your needs? If it is possible by hand then domapping
can do the same.
I am writing this issue here because
domapping
is one of the affected tools.The case is very simple. Right now, we have a circular reference in one of our schemas and it will occur more times in the near future, so trying to avoid this case doesn't look to be possible.
An example could be something like this: An owner has a car which has an owner. In this case, you can denormalize the schemas, but not in our real case. In our case, someone is trying to create a composite pattern using schemas.
Here is a little example:
Owner:
Car:
The solution in this case is easy: denormalize the data. However, we can not apply the same solution to our case.
We have been thinking about several solutions:
1) We can set the
type
of the inner item toobject
when we are generating the mapping and we detect the circular reference. It is not mapped properly but we avoid the problem.2) Set the inner field as a number in order to use it as a external identifier. In this way, you need to normalize the data from the client and denormalize again to send it to the client.
3) Try to avoid somehow the dependencies (Check in our case (CERN Analysis Preservation) all the schemas looking for a solution to these issues.) but it will not be reasonable.
Thanks a lot in advance.