Hi
I am following this example and I am having an issue linking the fields of the indices.
I have two indices one for nodes, and one for the links between them. My indices as follows:
nodes:
{
"_index" : "nodes",
"_type" : "doc",
"_id" : "1",
"_score" : 1.0,
"_source" : {
"name" : "actor0",
"score" : 0.87,
"group" : 1,
"index" : 22
}
},
{
"_index" : "nodes",
"_type" : "doc",
"_id" : "2",
"_score" : 1.0,
"_source" : {
"name" : "actor1",
"score" : 0.6,
"group" : 1,
"index" : 65
}
},
links:
{
"_index" : "links",
"_type" : "doc",
"_id" : "2",
"_score" : 1.0,
"_source" : {
"source" : 27,
"target" : 22,
"value" : 1.0
}
{
....
"data": [
{
"name": "node-data",
"url": {
"%context%": true,
"index": "nodes"
},
"format": { "property": "hits.hits" },
}
{
"name": "link-data",
"url": {
"%context%": true,
"index": "links"
},
"format": { "property": "hits.hits" },
}
],
"scales": [
{
"name": "color",
"type": "ordinal",
"domain": {"data": "node-data", "field": "group"},
"range": {"scheme": "category20c"}
}
],
"marks": [
{
"name": "nodes",
"type": "group",
"zindex": 1,
"from": {"data": "node-data"},
"on": [
{
"trigger": "fix",
"modify": "node",
"values": "fix === true ? {fx: node.x, fy: node.y} : {fx: fix[0], fy: fix[1]}"
},
{
"trigger": "!fix",
"modify": "node", "values": "{fx: null, fy: null}"
}
],
"marks": [{
"type": "symbol",
"encode": {
"update": {
"fill": {"scale": "color", "field": {"parent": "group"}},
"stroke": {"value": "white"},
"size": {"signal": "2 * nodeRadius * nodeRadius"},
"cursor": {"value": "pointer"}
}
}
}, {
"type": "text",
"interactive": false,
"encode": {
"enter": {
"fill": {
"value": "black"
},
"fontSize": {
"value": 12
},
"align": {
"value": "center"
},
"text": {
"field": {"parent": "name"}
},
"y": {
"value": -5
}
}
}
}],
"transform": [
{
"type": "force",
"iterations": 300,
"restart": {"signal": "restart"},
"static": {"signal": "static"},
"signal": "force",
"forces": [
{"force": "center", "x": {"signal": "cx"}, "y": {"signal": "cy"}},
{"force": "collide", "radius": {"signal": "nodeRadius"}},
{"force": "nbody", "strength": {"signal": "nodeCharge"}},
{"force": "link", "links": "link-data", "distance": {"signal": "linkDistance"}}
]
}
]
},
{
"type": "path",
"from": {"data": "link-data"},
"interactive": false,
"encode": {
"update": {
"stroke": {"value": "#ccc"},
"strokeWidth": {"value": 0.5}
}
},
"transform": [
{
"type": "linkpath",
"require": {"signal": "force"},
"shape": "line",
"sourceX": "datum.source.x", "sourceY": "datum.source.y",
"targetX": "datum.target.x", "targetY": "datum.target.y"
}
]
}
]
}
I am able to load the two indices but I do not know how to reference them, I am using
to get the data, I also tried to filter the data by using _source : ["field","field"]
but that did not work, and I am having missing: undefined
error
Thanks.