0

I've somethinh like it:

  • MainObject
    • ~3000x SubObjects
      • Each sub ojects have ~2 SubSubObjects
        • Idem: ~1 SubSubSubObject

For each subOject I need to get a mainObject information (array of integer), for the moment when I had the MainObject in database with all its subObjects (via command in console) I duplicate the array for all objects (thousands duplication...) when I need to edit this array, I re-index all again... I'm sure I can do it better.

In the document I've see it exists many possibilities: object, nested, parent/child... But I don't really know which is the better...

And in an other post, someone explain me how to do with nested document, with aggregation... But I can't do it... And more I read, more I've doubt about the nested method...

Thank you for your help

Edit, simplified arborescence in JSON of my entities (in Doctrine)

{
  "public": false,
  "authorized_users": [1, 23, 51],
  "chromosomes": [
    {
      "name": "C1",
      "locus": [
    {
      "name": "locus1",
      "features": [
        {
          "name": "feature1",
          "products": [
            {
              "name": "product1"
              //...
            }
          ]
        }
      ]
    }
      ]
    }
  ]
}

And I just do search on name for locus, features and products, but with a filter on public and authorized_users, thats why I do objects like (in Elasticsearch):

{
  "_type": "locus",
  "name": "locus1",
  "public": false,
  "authorized_users": [1, 23, 51],
},
{
  "_type": "locus",
  "name": "locus2",
  "public": false,
  "authorized_users": [1, 23, 51],
}

{
  "_type": "feature",
  "name": "feature1",
  "public": false,
  "authorized_users": [1, 23, 51],
}
mpiot
  • 1,482
  • 2
  • 15
  • 36
  • This answer might help: http://stackoverflow.com/questions/35153578/map-a-book-in-elasticsearch-with-many-levels-nested-vs-parent-child-relationshi/35153715#35153715 In your case, clearly nested or parent/child are not the way to go – Val Apr 18 '17 at 12:06
  • Thanks, yes apparently... I think keep what I do actually, because nested do the same, and I rarely change the shared information. Just search how I can in Symfony with FosElastica create a service than listen the update event of Strain, and run re-index. – mpiot Apr 18 '17 at 12:35
  • If the shared info changes rarely, then using nested document is even less appropriate. You should really consider denormalizing your data like in the linked answer. – Val Apr 18 '17 at 12:39
  • Yes, I do something close to it. I've an object for each subObject, and each subObject is independant. Because I only need subobject in elasticsearch, never the main object. – mpiot Apr 18 '17 at 12:55
  • Note that it would be easier if you provided some sample documents to better illustrate your case. People might be more inclined to help if they have something to chew on. – Val Apr 18 '17 at 12:58
  • @Val: I've edit my first message. – mpiot Apr 18 '17 at 13:09

0 Answers0