Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Which model is better for elasticsearch indexing?

I have 2 JSON model that can represented model for elasticsearch indexing. First :

{
"id" : 1,
"nama" : "satu", 
"child" : {
    "id" : 2,
    "nama" : "dua",
    "child" : [
        {
            "id" : 3
            "nama" : "tiga"
        },
        {
            "id" : 4,
            "nama" : "empat"
        }
    }
}

}

And second :

[{
    "parent1id" : 1,
    "parent1nama" : "satu",
    "parent2id" : 2,
    "parent2nama" : "dua",
    "id" : 3,
    "nama" : "tiga"
},
{
    "parent1id" : 1,
    "parent1nama" : "satu",
    "parent2id" : 2,
    "parent2nama" : "dua",
    "id" : 4,
    "nama" : "empat"
}]

Actually both first and second have the same meaning and created for elasticsearch indexing. I think the first model is less redundant, and the second ones is more redundant. But the first ones, represented as 1 elastic record, but the second ones represented as 2 elastic record. This thing will impact when I do searching for example ID = 3. The first ones, will return the whole record, and the second ones will return the record that the ID = 3.

So, I want your suggestion all, which model better for elasticsearch. Thanks...

Answer*

Cancel