# Indexing a threaded conversation

**URL:** <https://discuss.elastic.co/t/indexing-a-threaded-conversation/244257>\
**Category:** Elasticsearch\
**Created:** [August 8, 2020, 4:26pm UTC](https://discuss.elastic.co/t/indexing-a-threaded-conversation/244257 "2020-08-08T16:26:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dansei](https://avatars.discourse-cdn.com/v4/letter/d/e19b73/32.png) [@dansei](https://discuss.elastic.co/u/dansei)\
**Post date:** [August 8, 2020, 4:26pm UTC](https://discuss.elastic.co/t/indexing-a-threaded-conversation/244257/1 "2020-08-08T16:26:05Z")

</div>

I would like to use Elasticsearch to index and search a threaded conversation, like a blog's comments where there are top-level comments and replies to those comments.

I have tried making a single document like this, with a Nested `comments` field, with each comment having an ID, a parent ID, and a list of child reply IDs.

```
{
    "comments": [
        {
            "id": 1,
            "text": "nice post",
            "replies": [2]
        },
        {
            "id": 2,
            "parent": 1,
            "text": "Thanks for reading my blog!"
        },
        {
            "id": 3,
            "text": "very helpful"
        }
    ]
}

```

This works to an extent because I can search through the `comments.text` fields and find matches. But I think the API gives me back only the matching text, removed from the context of the adjacent fields that tell me where the comment is in the discussion.

Is this a good way to store this data?

I could also put each comment as a separate document, with a common conversation ID (e.g., the blog post ID), and the parent and child IDs. I'm not sure if this is a good use case for "join" queries or not.

---

<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:** [September 5, 2020, 4:26pm UTC](https://discuss.elastic.co/t/indexing-a-threaded-conversation/244257/2 "2020-09-05T16:26:11Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
