# What is depth weight represent in graph

**URL:** <https://discuss.elastic.co/t/what-is-depth-weight-represent-in-graph/113733>\
**Category:** Kibana\
**Tags:** elastic-stack-graph\
**Created:** [January 2, 2018, 7:08am UTC](https://discuss.elastic.co/t/what-is-depth-weight-represent-in-graph/113733 "2018-01-02T07:08:42Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![krishnaraj221193](https://avatars.discourse-cdn.com/v4/letter/k/85e7bf/32.png) [@krishnaraj221193](https://discuss.elastic.co/u/krishnaraj221193)\
**Post date:** [January 2, 2018, 7:08am UTC](https://discuss.elastic.co/t/what-is-depth-weight-represent-in-graph/113733/1 "2018-01-02T07:08:42Z")

</div>

hi  
Im working on graph and im seeing depth and weight in vertex and connection on response but im not able to understand what is that.  
im trying to make parent child relationship using copy\_to having id of parent but im not getting proper search like at one i get 5 vertex after that i need to do spidering operation to get more result can i get all vertex at one shot.

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [January 2, 2018, 9:31am UTC](https://discuss.elastic.co/t/what-is-depth-weight-represent-in-graph/113733/2 "2018-01-02T09:31:44Z")

</div>

> [@krishnaraj221193](#):
>
> im seeing depth and weight in vertex and connection on response but im not able to understand what is that

Hi. The [API docs](https://www.elastic.co/guide/en/elasticsearch/reference/6.1/graph-explore-api.html#CO349-1) describe as follows:

```
The weight attribute specifies a significance score. 
The depth attribute specifies the hop-level at which the term was first encountered.

```

Each nesting of a `connections` section in the request represents a "hop" that will bring in a new set of terms with the same depth but potentially different significance scores.  
Hope this helps.

---

<div class="post-metadata">

**Author:** ![krishnaraj221193](https://avatars.discourse-cdn.com/v4/letter/k/85e7bf/32.png) [@krishnaraj221193](https://discuss.elastic.co/u/krishnaraj221193)\
**Post date:** [January 2, 2018, 2:04pm UTC](https://discuss.elastic.co/t/what-is-depth-weight-represent-in-graph/113733/3 "2018-01-02T14:04:31Z")

</div>

hi,  
thanks for the reply I need to know how to get all related documents without spidering operations means after a request I need all documents at once

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [January 2, 2018, 2:10pm UTC](https://discuss.elastic.co/t/what-is-depth-weight-represent-in-graph/113733/4 "2018-01-02T14:10:49Z")

</div>

> [@krishnaraj221193](#):
>
> I need to know how to get all related documents

The graph API is designed to discover related _terms_ - documents are only used to give weight to the links between pairs of terms. If you need to drill-down into the details of the documents behind these connections you'll need to perform a follow-up query with the list of discovered terms.

---

<div class="post-metadata">

**Author:** ![krishnaraj221193](https://avatars.discourse-cdn.com/v4/letter/k/85e7bf/32.png) [@krishnaraj221193](https://discuss.elastic.co/u/krishnaraj221193)\
**Post date:** [January 3, 2018, 3:57am UTC](https://discuss.elastic.co/t/what-is-depth-weight-represent-in-graph/113733/5 "2018-01-03T03:57:35Z")

</div>

Hi  
Once again thanks for the reply im trying to get all vertex in a single request means get all vertex at once instead of doing spidering operation on the previous requests is it posibble

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [January 3, 2018, 8:37am UTC](https://discuss.elastic.co/t/what-is-depth-weight-represent-in-graph/113733/6 "2018-01-03T08:37:21Z")

</div>

> [@krishnaraj221193](#):
>
> how to get all related documents

> [@krishnaraj221193](#):
>
> im trying to get all vertex

I'm unclear what you need - vertices (which are terms) or documents?

---

<div class="post-metadata">

**Author:** ![krishnaraj221193](https://avatars.discourse-cdn.com/v4/letter/k/85e7bf/32.png) [@krishnaraj221193](https://discuss.elastic.co/u/krishnaraj221193)\
**Post date:** [January 3, 2018, 9:28am UTC](https://discuss.elastic.co/t/what-is-depth-weight-represent-in-graph/113733/7 "2018-01-03T09:28:07Z")

</div>

Means getting all matching nodes at a single request

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [January 3, 2018, 9:32am UTC](https://discuss.elastic.co/t/what-is-depth-weight-represent-in-graph/113733/8 "2018-01-03T09:32:27Z")

</div>

When you nest `connections` clauses in your request you are asking for another "hop" into the graph of connections. Maybe some example input data and a required output result would help clarify the problem that we are trying to solve here

---

<div class="post-metadata">

**Author:** ![krishnaraj221193](https://avatars.discourse-cdn.com/v4/letter/k/85e7bf/32.png) [@krishnaraj221193](https://discuss.elastic.co/u/krishnaraj221193)\
**Post date:** [January 3, 2018, 9:51am UTC](https://discuss.elastic.co/t/what-is-depth-weight-represent-in-graph/113733/9 "2018-01-03T09:51:57Z")

</div>

can i get all nodes and connections at once like  
first request is giving some 10 nodes then through spidering operations i need to get further more relations so on continue...

Instead of above is there a way to get all vertex and related vertex

---

<div class="post-metadata">

**Author:** ![krishnaraj221193](https://avatars.discourse-cdn.com/v4/letter/k/85e7bf/32.png) [@krishnaraj221193](https://discuss.elastic.co/u/krishnaraj221193)\
**Post date:** [January 3, 2018, 9:53am UTC](https://discuss.elastic.co/t/what-is-depth-weight-represent-in-graph/113733/10 "2018-01-03T09:53:46Z")

</div>

Is there a way to get parent child relationship for same index type means i know we cant have self reference but some thing else we can have????

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [January 3, 2018, 10:36am UTC](https://discuss.elastic.co/t/what-is-depth-weight-represent-in-graph/113733/11 "2018-01-03T10:36:56Z")

</div>

Here is an example where documents queried contain an array of 2 or more IDs held in an `entref_id` array:

```
{
	"query": {
		"query_string": {
			"query": "myseedquery"
		}
	},
	"controls": {
		"use_significance": false,
		"sample_size": 2000,
		"timeout": 5000
	},
	"vertices": [
		{
			"field": "entref_id",
			"size": 50,
			"min_doc_count": 1
		}
	],
	"connections": {
		"vertices": [
			{
				"field": "entref_id",
				"size": 50,
				"min_doc_count": 1
			}
		]
	}
}

```

Note that it uses a seed query to start the exploration and retrieves up to 50 matching vertices. It then finds (independent of the seed query constraints) up to 50 more vertices that are connected to the initial vertices. Nesting more `connections` clauses would further the exploration achieved with this one request.

---

<div class="post-metadata">

**Author:** ![krishnaraj221193](https://avatars.discourse-cdn.com/v4/letter/k/85e7bf/32.png) [@krishnaraj221193](https://discuss.elastic.co/u/krishnaraj221193)\
**Post date:** [January 3, 2018, 11:00am UTC](https://discuss.elastic.co/t/what-is-depth-weight-represent-in-graph/113733/12 "2018-01-03T11:00:59Z")

</div>

if i want more than 50 vertices lets say all vertices what should i do

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [January 3, 2018, 11:04am UTC](https://discuss.elastic.co/t/what-is-depth-weight-represent-in-graph/113733/13 "2018-01-03T11:04:51Z")

</div>

> [@krishnaraj221193](#):
>
> if i want more than 50 vertices lets say all vertices what should i do

Increase the number. Clearly handling a billion results in a single JSON response would not be a good thing for the server or the client to attempt. That is a limitation of trying to perform this analysis within a single request-response paradigm.

---

<div class="post-metadata">

**Author:** ![krishnaraj221193](https://avatars.discourse-cdn.com/v4/letter/k/85e7bf/32.png) [@krishnaraj221193](https://discuss.elastic.co/u/krishnaraj221193)\
**Post date:** [January 3, 2018, 11:06am UTC](https://discuss.elastic.co/t/what-is-depth-weight-represent-in-graph/113733/14 "2018-01-03T11:06:19Z")

</div>

Im trying to make relation with same index type in elasticsearch but its not possible is there a way to solve means self referencing using parent child for same type

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [January 3, 2018, 11:07am UTC](https://discuss.elastic.co/t/what-is-depth-weight-represent-in-graph/113733/15 "2018-01-03T11:07:41Z")

</div>

Please post example JSON for the documents you want to join

---

<div class="post-metadata">

**Author:** ![krishnaraj221193](https://avatars.discourse-cdn.com/v4/letter/k/85e7bf/32.png) [@krishnaraj221193](https://discuss.elastic.co/u/krishnaraj221193)\
**Post date:** [January 3, 2018, 11:10am UTC](https://discuss.elastic.co/t/what-is-depth-weight-represent-in-graph/113733/16 "2018-01-03T11:10:38Z")

</div>

Lets say i have one person named anna who is wife of dave since both are in person type  
anna belong to dave

Anna --wife--\> dave

here dave is parent of anna

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [January 3, 2018, 11:13am UTC](https://discuss.elastic.co/t/what-is-depth-weight-represent-in-graph/113733/17 "2018-01-03T11:13:14Z")

</div>

I need to see JSON for how these concepts are represented as documents in your index/indices.

If you haven't worked out a design for your docs yet maybe you can start by listing the entities and relationships that are part of the business problem you are trying to solve.

---

<div class="post-metadata">

**Author:** ![krishnaraj221193](https://avatars.discourse-cdn.com/v4/letter/k/85e7bf/32.png) [@krishnaraj221193](https://discuss.elastic.co/u/krishnaraj221193)\
**Post date:** [January 5, 2018, 3:31am UTC](https://discuss.elastic.co/t/what-is-depth-weight-represent-in-graph/113733/18 "2018-01-05T03:31:09Z")

</div>

hi sir,  
How can i know which vertex is parent in graph since i dont see any direction on connections  
so which is parent vertex and which is child vertex

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [January 5, 2018, 10:35am UTC](https://discuss.elastic.co/t/what-is-depth-weight-represent-in-graph/113733/19 "2018-01-05T10:35:00Z")

</div>

It is possible but needs some workarounds.  
In general graph theory "parent" and "child" would be role metadata used to describe each of the nodes on an `edge` or in a directed graph the direction of the edge could imply the relationship (e.g. children always point to parents).  
The thing to remember about the elasticsearch graph view of data is that the edges (we call them "connections") are _aggregate_ edges - there could be ten thousand banking documents recording money transactions back and forth between A and B but we would summarise all these interactions in a single undirected connection between A and B. This is both a strength and a weakness.

If you want to capture the details of a parent/child relationship in a graph visualization you'd need to introduce the relationship as a special node/vertex term. Each node in the relationship would then need to define and edge-like document asserting that they are connected to this relationship-defining term. Here's how that would look for a grandparent -\> parent -\>child definition:

```
PUT relationships
{
  "settings": {
	"number_of_replicas": 0,
	"number_of_shards": 1
  },
  "mappings": {
	"relationship": {
	  "properties": {
		"id": {
		  "type": "keyword"
		},
		"parent->child": {
		  "type": "keyword"
		}
	  }
	}
  }
}
POST /relationships/relationship/_bulk
{ "index" : {} }
{"id": "A", "parent->child":"A is parent Of B"}
{ "index" : {} }
{"id": "B", "parent->child":"A is parent Of B"}
{ "index" : {} }
{"id": "B", "parent->child":"B is parent Of C"}
{ "index" : {} }
{"id": "C", "parent->child":"B is parent Of C"}

```

 ![Kibana_🔊](https://us1.discourse-cdn.com/elastic/original/3X/3/b/3bb8124bb959fc483e9c0c0e922749ee8074636a.png)

---

<div class="post-metadata">

**Author:** ![krishnaraj221193](https://avatars.discourse-cdn.com/v4/letter/k/85e7bf/32.png) [@krishnaraj221193](https://discuss.elastic.co/u/krishnaraj221193)\
**Post date:** [January 8, 2018, 7:10am UTC](https://discuss.elastic.co/t/what-is-depth-weight-represent-in-graph/113733/20 "2018-01-08T07:10:57Z")

</div>

Thanks for the reply sir,  
In the above example i can see document with id=b is created twice which is duplicate which dont require my document is like below format  
My document is  
relationships/relationship/\_bulk  
{ "id":1,"name":"a" }  
{ "id":2,"name":"b","parent":1 }  
{ "id":3,"name":"c","parent":2 }  
{ "id":4,"name":"d","parent":3 }  
{ "id":5,"name":"e","parent":4 }  
{ "id":6,"name":"f","parent":5 }  
{ "id":7,"name":"g","parent":6 }  
{ "id":8,"name":"h","parent":7 }  
{ "id":9,"name":"i","parent":8 }  
{ "id":10,"name":"j","parent":9 }  
{ "id":11,"name":"k","parent":11 }  
....

so when i search for name=d i need to get all its parent and all its child without spidering operation means in single request get

request is name =d

output should be a,b,c,d,e,f,g,h,i,j,k.... because it all is related directly or indirectly to name=d  
it should be from one request

[Next page](https://discuss.elastic.co/t/what-is-depth-weight-represent-in-graph/113733.md?page=2)
