I am new with elastic search and looking for the best solution with which i can create a feed module which have time based feeds along with there group and comment.
I learned little and come up with following.
PUT /group
    {
      "mappings": {
        "groupDetail": {},
        "content": {
          "_parent": {
            "type": "groupDetail" 
          }
        },
        "comment": {
          "_parent": {
            "type": "content" 
          }
        }
      }
    }so that will be placed separately as per index.
but than after i found one post where i found that parent child is costly operation for search than nested objects.
something like following is two group(feed) having details with content and comments as nested element.
{
  "_index": "group",
  "_type": "groupDetail",
  "_id": 6829,
  "_score": 1,
  "_source": {
    "groupid": 6829,
    "name": "Jignesh Public",
    "insdate": "2016-10-01T04:09:33.916Z",
    "upddate": "2017-04-19T05:19:40.281Z",
    "isVerified": true,
    "tags": [
      "spotrs",
      "surat"
    ],
    "content": [
      {
        "contentid": 1,
        "type": "1",
        "byUser": 5858,
        "insdate": "2016-10-01 11:20",
        "info": [
          {
            "t": 1,
            "v": "lorem ipsum long text 1"
          },
          {
            "t": 2,
            "v": "http://www.imageurl.com/1"
          }
        ],
        "comments": [
          {
            "byuser": 5859,
            "comment": "Comment 1",
            "upddate": "2016-10-01T04:09:33.916Z"
          },
          {
            "byuser": 5860,
            "comment": "Comment 2",
            "upddate": "2016-10-01T04:09:33.916Z"
          }
        ]
      },
      {
        "contentid": 2,
        "type": "2",
        "byUser": 5859,
        "insdate": "2016-10-01 11:20",
        "info": [
          {
            "t": 4,
            "v": "http://www.videoURL.com/1"
          }
        ],
        "comments": [
          {
            "byuser": 5859,
            "comment": "Comment 1",
            "upddate": "2016-10-01T04:09:33.916Z"
          },
          {
            "byuser": 5860,
            "comment": "Comment 2",
            "upddate": "2016-10-01T04:09:33.916Z"
          }
        ]
      }
    ]
  }
}
{
  "_index": "group",
  "_type": "groupDetail",
  "_id": 6849,
  "_score": 1,
  "_source": {
    "groupid": 6849,
    "name": "Xyz Group Public",
    "insdate": "2016-10-01T04:09:33.916Z",
    "upddate": "2017-04-19T05:19:40.281Z",
    "isVerified": false,
    "tags": [
      "spotrs",
      "food"
    ],
    "content": [
      {
        "contentid": 3,
        "type": "1",
        "byUser": 5858,
        "insdate": "2016-10-01 11:20",
        "info": [
          {
            "t": 1,
            "v": "lorem ipsum long text 3"
          },
          {
            "t": 2,
            "v": "http://www.imageurl.com/1"
          }
        ],
        "comments": [
          {
            "byuser": 5859,
            "comment": "Comment 1",
            "upddate": "2016-10-01T04:09:33.916Z"
          },
          {
            "byuser": 5860,
            "comment": "Comment 2",
            "upddate": "2016-10-01T04:09:33.916Z"
          }
        ]
      },
      {
        "contentid": 4,
        "type": "2",
        "byUser": 5859,
        "insdate": "2016-10-01 11:20",
        "info": [
          {
            "t": 4,
            "v": "http://www.videoURL.com/1"
          }
        ],
        "comments": [
          {
            "byuser": 5859,
            "comment": "Comment 1",
            "upddate": "2016-10-01T04:09:33.916Z"
          },
          {
            "byuser": 5860,
            "comment": "Comment 2",
            "upddate": "2016-10-01T04:09:33.916Z"
          }
        ]
      }
    ]
  }
}now if i try to think with nested object than i confused if user add comment very frequently than reindexing factor will effect?
So main think i want to ask is which is the best approach with which i can add comment frequently and my content searching result is also faster.
So, we can infer:
As far as I understand your problem, you should use parent/child.
Furthermore, you should also take the rate of searching a comment comparing to adding a comment into account:
By the way, you may combine both of them:
If you do not specify more detailed info other than very frequently it is going to be hard to come up with a recommendation. Also you have not mentioned how your data looks like. A comment in a blog post might be happening rare, even in heated discussions. A comment/reply in a forum post (that will result in a huge document) might be sth very different. I'd personally start with nested and see how it goes, but I also do not know all the requirements, so this might be a very wrong answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With