# Indexing a forum with elasticsearch

**URL:** <https://discuss.elastic.co/t/indexing-a-forum-with-elasticsearch/5921>\
**Category:** Elasticsearch\
**Created:** [November 21, 2011, 9:39am UTC](https://discuss.elastic.co/t/indexing-a-forum-with-elasticsearch/5921 "2011-11-21T09:39:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vibrant](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@vibrant](https://discuss.elastic.co/u/vibrant)\
**Post date:** [November 21, 2011, 9:39am UTC](https://discuss.elastic.co/t/indexing-a-forum-with-elasticsearch/5921/1 "2011-11-21T09:39:23Z")

</div>

Hello,

I'd like to ask what is the best practice for indexing forum threads. My  
problem is that a thread could have 200 posts, and if there is one document  
per each thread in the index, then when somebody adds post number 201 - I  
have to reindex all 201 posts.

Is there any best practice for this with elastic search?

Thanks,

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 21, 2011, 10:32am UTC](https://discuss.elastic.co/t/indexing-a-forum-with-elasticsearch/5921/2 "2011-11-21T10:32:34Z")

</div>

Hi,

IMO, I always ask myself : "what I am looking for ?".  
In your case, "Am I looking for Threads talking about something ?" or "Am I  
looking for comments talking about something ?".

This could be important in term of scoring.

Imagine the following case :  
I have 2 threads :  
The first one has 10 comments with the word elasticsearch in each one  
The second one has 1 comment with the word elasticsearch

If you index individuals comments, the score of the 11 comments will be the  
same.  
If you index threads, the score of the first thread will be higher than the  
second one.

That said, I will index threads with comments because I'm looking for threads  
talking about what I m searching for and I want to find the more relevant item.

If you want to find a Thread talking about elasticsearch AND lucene, you will  
find it if you index the whole Thread even if the two words are in individual  
comments. But you won't find it if you index only comments.

Whatever you choose : using array of comments or nested comments, you will have  
to send the full Thread to Elastic search.

That's the way I would certainly handle your use case.  
HTH  
David.

--  
David Pilato  
[http://dev.david.pilato.fr/](http://dev.david.pilato.fr/)  
Twitter : @dadoonet

Le 21 novembre 2011 à 10:39, vibrant [paranite@gmail.com](mailto:paranite@gmail.com) a écrit :

> Hello,
> 
> I'd like to ask what is the best practice for indexing forum threads. My  
> problem is that a thread could have 200 posts, and if there is one document  
> per each thread in the index, then when somebody adds post number 201 - I  
> have to reindex all 201 posts.
> 
> Is there any best practice for this with Elasticsearch?
> 
> Thanks,

---

<div class="post-metadata">

**Author:** ![vineeth\_mohan](https://avatars.discourse-cdn.com/v4/letter/v/bc79bd/32.png) [@vineeth\_mohan](https://discuss.elastic.co/u/vineeth_mohan)\
**Post date:** [November 21, 2011, 11:26am UTC](https://discuss.elastic.co/t/indexing-a-forum-with-elasticsearch/5921/3 "2011-11-21T11:26:23Z")

</div>

May be you can use parent child documents -

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

Thanks  
Vineeth

On Mon, Nov 21, 2011 at 4:02 PM, [david@pilato.fr](mailto:david@pilato.fr) [david@pilato.fr](mailto:david@pilato.fr) wrote:

> \*\*
> 
> Hi,
> 
> IMO, I always ask myself : "what I am looking for ?".
> 
> In your case, "Am I looking for Threads talking about something ?" or "Am  
> I looking for comments talking about something ?".
> 
> This could be important in term of scoring.
> 
> Imagine the following case :
> 
> I have 2 threads :
> 
> The first one has 10 comments with the word elasticsearch in each one
> 
> The second one has 1 comment with the word elasticsearch
> 
> If you index individuals comments, the score of the 11 comments will be  
> the same.
> 
> If you index threads, the score of the first thread will be higher than  
> the second one.
> 
> That said, I will index threads with comments because I'm looking for  
> threads talking about what I m searching for and I want to find the more  
> relevant item.
> 
> If you want to find a Thread talking about elasticsearch AND lucene, you  
> will find it if you index the whole Thread even if the two words are in  
> individual comments. But you won't find it if you index only comments.
> 
> Whatever you choose : using array of comments or nested comments, you will  
> have to send the full Thread to Elastic search.
> 
> That's the way I would certainly handle your use case.
> 
> HTH
> 
> David.
> 
> --  
> David Pilato  
> [http://dev.david.pilato.fr/](http://dev.david.pilato.fr/)  
> Twitter : @dadoonet
> 
> Le 21 novembre 2011 à 10:39, vibrant [paranite@gmail.com](mailto:paranite@gmail.com) a écrit :
> 
> > Hello,
> > 
> > I'd like to ask what is the best practice for indexing forum threads.  
> > My  
> > problem is that a thread could have 200 posts, and if there is one  
> > document  
> > per each thread in the index, then when somebody adds post number 201 -  
> > I  
> > have to reindex all 201 posts.
> > 
> > Is there any best practice for this with Elasticsearch?
> > 
> > Thanks,

---

<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:48am UTC](https://discuss.elastic.co/t/indexing-a-forum-with-elasticsearch/5921/4 "2017-07-06T03:48:06Z")

</div>


