json-mapper-json
json-mapper-json copied to clipboard
$root keyword problem
Hello, I'm having an issue with using the $root keyword. Here is my code:
var source = { "data": { "items": [ {"item": "one"}, {"item": "two"} ] } }
var template = { "query": { path: "data.items", nested: { "item": { path: "$item" } } } }
As a mapping result I will get this:
{ "query": [{ "term":{"item":"one} }, { "term":{"item":"two"} }] }
But when I change in the template 'path: "data.items"' to 'path: "$root.data.items"', I will get this:
{ "query": { "term": [ {"term":{"item":"one}}, {"term":{"item":"two"}} ] } }
So there is a strange behavior of the $root keyword.
You mean this template without $root
right:
{
"query": {
path: "data.items",
nested: {
"term": {
path: "$item"
}
}
},
}
Yes somethings is weird