# Search through friends graph

**URL:** https://discuss.elastic.co/t/search-through-friends-graph/10975
**Category:** Elasticsearch
**Created:** [March 2, 2013, 12:21pm UTC](https://discuss.elastic.co/t/search-through-friends-graph/10975 "2013-03-02T12:21:15Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![me1](https://avatars.discourse-cdn.com/v4/letter/m/a4c791/32.png) [@me1](https://discuss.elastic.co/u/me1)
#### Post date: [March 2, 2013, 12:21pm UTC](https://discuss.elastic.co/t/search-through-friends-graph/10975/1 "2013-03-02T12:21:15Z")

</div>

Hello guys,

I'm having some trouble in the following context:

@foo is following two friends, @bar and @baz  
@bar follows @foo and @quux  
@baz follows @quux and @wiix

I need to fetch all comments made by who @foo's following, @bar and @baz.  
The problem is that I need also, later, fetch all comments made by who  
@foo's followers are following, @quux and @wiix. Is there a way to do it  
with ElasticSearch?

[]s,  
Lucas

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Mark\_Harwood1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood1/32/101255_2.png) [@Mark\_Harwood1](https://discuss.elastic.co/u/Mark_Harwood1)
#### Post date: [March 4, 2013, 4:12pm UTC](https://discuss.elastic.co/t/search-through-friends-graph/10975/2 "2013-03-04T16:12:04Z")

</div>

It's do-able but that's the sort of problem where the volume of search  
terms and results grows exponentially with each "hop" or degree of  
separation you follow.  
You can hit one single guy who follows thousands of others and they all end  
up becoming new search terms as you explore the graph. If each of them  
follow many people you reach a lot of content in only 2 hops.  
Each unique search term will cost you time in random disk seeks so it gets  
expensive fast. That is not a limitation of elastic-search - just graph  
searches in general.

On Saturday, March 2, 2013 12:21:15 PM UTC, [m...@lsmagalhaes.com](mailto:m...@lsmagalhaes.com) wrote:

> Hello guys,
> 
> I'm having some trouble in the following context:
> 
> @foo is following two friends, @bar and @baz  
> @bar follows @foo and @quux  
> @baz follows @quux and @wiix
> 
> I need to fetch all comments made by who @foo's following, @bar and @baz.  
> The problem is that I need also, later, fetch all comments made by who  
> @foo's followers are following, @quux and @wiix. Is there a way to do it  
> with Elasticsearch?
> 
> s,  
> Lucas

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)
#### Post date: [March 4, 2013, 4:32pm UTC](https://discuss.elastic.co/t/search-through-friends-graph/10975/3 "2013-03-04T16:32:55Z")

</div>

Yes, it depends on when traversal takes place.

If the social graph can be traversed at indexing time, the leaves can be  
indexed as documents, with anchor IDs and other attributes (e.g. the  
user id, the node path, relationships of that node), and searching for  
the leave attributes can be very fast. The process is known as  
denormalization.

Traversing social graphs for collecting all(!) comments at search time  
is usually a bad idea. There are often more contraints so the result set  
can be built more efficiently. But graph traversal is not how  
Elasticsearch works.

Jörg

Am 04.03.13 17:12, schrieb Mark Harwood:

> Each unique search term will cost you time in random disk seeks so it  
> gets expensive fast. That is not a limitation of elastic-search - just  
> graph searches in general.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 6, 2017, 2:48am UTC](https://discuss.elastic.co/t/search-through-friends-graph/10975/4 "2017-07-06T02:48:30Z")

</div>


