json-mapper-json icon indicating copy to clipboard operation
json-mapper-json copied to clipboard

$root keyword problem

Open SergeyKokichev opened this issue 8 years ago • 1 comments

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.

SergeyKokichev avatar Dec 20 '16 06:12 SergeyKokichev

You mean this template without $root right:

{
	"query": {
		path: "data.items",
		nested: {
			"term": {
				path: "$item"
			}
		}
	},
}

Yes somethings is weird

marchah avatar Dec 23 '16 21:12 marchah