# ES for a social network application

**URL:** <https://discuss.elastic.co/t/es-for-a-social-network-application/7416>\
**Category:** Elasticsearch\
**Created:** [April 20, 2012, 8:58am UTC](https://discuss.elastic.co/t/es-for-a-social-network-application/7416 "2012-04-20T08:58:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![alheim](https://avatars.discourse-cdn.com/v4/letter/a/dec6dc/32.png) [@alheim](https://discuss.elastic.co/u/alheim)\
**Post date:** [April 20, 2012, 8:58am UTC](https://discuss.elastic.co/t/es-for-a-social-network-application/7416/1 "2012-04-20T08:58:22Z")

</div>

Hi,

We build a social network application and we use ES to enable our users to  
browse content with facets and text search.

Everything works fine.

Now we would like to enable the users to filter what they have read or not,  
what they have starred... .

_Example :_

I want all the documents containing MAPPING, tagged with ES which I've not  
already read, and the corresponding facets

Here comes the issue.

I'm destroying my brain thinking about a way to model this.

1- For each posts, I add a nested object containing the userId and the  
readDate of ALL the readers. What if there are 100 000 users or more ?

Is it an issue for ES to manage so much nested object ?

Is it possible to retrieve only the nested object corresponding to the user  
who makes the query ?

2- Use a parent child mapping. But joins are not possible. Or I miss  
something.

3- Get the documents without the user's specific data and query the  
database to get them. But the facet's count will be wrong.

Any idea ? I'm pretty sure I'm not the only one to have this issue.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [April 21, 2012, 2:56pm UTC](https://discuss.elastic.co/t/es-for-a-social-network-application/7416/2 "2012-04-21T14:56:12Z")

</div>

You could try and use parent child, where the child document is an user  
specific document indicating if its starred or when it was read. Then, you  
can use has\_child filter for it.

On Fri, Apr 20, 2012 at 11:58 AM, Alexandre Heimburger \<  
[ahb@bluekiwi-software.com](mailto:ahb@bluekiwi-software.com)\> wrote:

> Hi,
> 
> We build a social network application and we use ES to enable our users to  
> browse content with facets and text search.
> 
> Everything works fine.
> 
> Now we would like to enable the users to filter what they have read or  
> not, what they have starred... .
> 
> _Example :_
> 
> I want all the documents containing MAPPING, tagged with ES which I've not  
> already read, and the corresponding facets
> 
> Here comes the issue.
> 
> I'm destroying my brain thinking about a way to model this.
> 
> 1- For each posts, I add a nested object containing the userId and the  
> readDate of ALL the readers. What if there are 100 000 users or more ?
> 
> Is it an issue for ES to manage so much nested object ?
> 
> Is it possible to retrieve only the nested object corresponding to the  
> user who makes the query ?
> 
> 2- Use a parent child mapping. But joins are not possible. Or I miss  
> something.
> 
> 3- Get the documents without the user's specific data and query the  
> database to get them. But the facet's count will be wrong.
> 
> Any idea ? I'm pretty sure I'm not the only one to have this issue.

---

<div class="post-metadata">

**Author:** ![alheim](https://avatars.discourse-cdn.com/v4/letter/a/dec6dc/32.png) [@alheim](https://discuss.elastic.co/u/alheim)\
**Post date:** [July 24, 2012, 3:31pm UTC](https://discuss.elastic.co/t/es-for-a-social-network-application/7416/3 "2012-07-24T15:31:12Z")

</div>

Thanks. It's working perfectly and so fast. ES is awesome.

I should write a tutorial on how we implement a social network with ES.

On Saturday, 21 April 2012 16:56:12 UTC+2, kimchy wrote:

> You could try and use parent child, where the child document is an user  
> specific document indicating if its starred or when it was read. Then, you  
> can use has\_child filter for it.
> 
> On Fri, Apr 20, 2012 at 11:58 AM, Alexandre Heimburger \<  
> [ahb@bluekiwi-software.com](mailto:ahb@bluekiwi-software.com)\> wrote:
> 
> > Hi,
> > 
> > We build a social network application and we use ES to enable our users  
> > to browse content with facets and text search.
> > 
> > Everything works fine.
> > 
> > Now we would like to enable the users to filter what they have read or  
> > not, what they have starred... .
> > 
> > _Example :_
> > 
> > I want all the documents containing MAPPING, tagged with ES which I've  
> > not already read, and the corresponding facets
> > 
> > Here comes the issue.
> > 
> > I'm destroying my brain thinking about a way to model this.
> > 
> > 1- For each posts, I add a nested object containing the userId and the  
> > readDate of ALL the readers. What if there are 100 000 users or more ?
> > 
> > Is it an issue for ES to manage so much nested object ?
> > 
> > Is it possible to retrieve only the nested object corresponding to the  
> > user who makes the query ?
> > 
> > 2- Use a parent child mapping. But joins are not possible. Or I miss  
> > something.
> > 
> > 3- Get the documents without the user's specific data and query the  
> > database to get them. But the facet's count will be wrong.
> > 
> > Any idea ? I'm pretty sure I'm not the only one to have this issue.

---

<div class="post-metadata">

**Author:** ![otisg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/otisg/32/492_2.png) [@otisg](https://discuss.elastic.co/u/otisg)\
**Post date:** [July 25, 2012, 6:17am UTC](https://discuss.elastic.co/t/es-for-a-social-network-application/7416/4 "2012-07-25T06:17:42Z")

</div>

Hi,

On Tuesday, July 24, 2012 11:31:12 AM UTC-4, Alexandre Heimburger wrote:

> Thanks. It's working perfectly and so fast. ES is awesome.
> 
> I should write a tutorial on how we implement a social network with ES.

That sounds interesting. Could you?

## Otis

Search Analytics - [Cloud Monitoring Tools & Services | Sematext](http://sematext.com/search-analytics/index.html)  
Scalable Performance Monitoring - [Sematext Monitoring | Infrastructure Monitoring Service](http://sematext.com/spm/index.html)

> On Saturday, 21 April 2012 16:56:12 UTC+2, kimchy wrote:
> 
> > You could try and use parent child, where the child document is an user  
> > specific document indicating if its starred or when it was read. Then, you  
> > can use has\_child filter for it.
> > 
> > On Fri, Apr 20, 2012 at 11:58 AM, Alexandre Heimburger \<  
> > [ahb@bluekiwi-software.com](mailto:ahb@bluekiwi-software.com)\> wrote:
> > 
> > > Hi,
> > > 
> > > We build a social network application and we use ES to enable our users  
> > > to browse content with facets and text search.
> > > 
> > > Everything works fine.
> > > 
> > > Now we would like to enable the users to filter what they have read or  
> > > not, what they have starred... .
> > > 
> > > _Example :_
> > > 
> > > I want all the documents containing MAPPING, tagged with ES which I've  
> > > not already read, and the corresponding facets
> > > 
> > > Here comes the issue.
> > > 
> > > I'm destroying my brain thinking about a way to model this.
> > > 
> > > 1- For each posts, I add a nested object containing the userId and the  
> > > readDate of ALL the readers. What if there are 100 000 users or more ?
> > > 
> > > Is it an issue for ES to manage so much nested object ?
> > > 
> > > Is it possible to retrieve only the nested object corresponding to the  
> > > user who makes the query ?
> > > 
> > > 2- Use a parent child mapping. But joins are not possible. Or I miss  
> > > something.
> > > 
> > > 3- Get the documents without the user's specific data and query the  
> > > database to get them. But the facet's count will be wrong.
> > > 
> > > Any idea ? I'm pretty sure I'm not the only one to have this issue.

---

<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, 3:19am UTC](https://discuss.elastic.co/t/es-for-a-social-network-application/7416/5 "2017-07-06T03:19:09Z")

</div>


