user3584146
user3584146

Reputation: 73

Deeply nested JSON documents in Apache Solr

I have a deeply nested document(pseudo structure as shown below):

[{
    "id": "1",
    "company_id": "1",
    "company_name": "company_1",
    "departments":[{
                 "dep1" : [{
                           "id" : 40,
                           "name" : xyz
                           },
                           {
                           "id" : 41,
                           "name" : xyr
                           }],
                "dep2": [{
                }]
            }]
    "employeePrograms" :[{
    }]
}]

How can I index these type of documents in Apache Solr? Documentation gives the idea of immediate child documents alone.

Upvotes: 4

Views: 2169

Answers (1)

Altenrion
Altenrion

Reputation: 774

Unfortunatelly i'm don't have huge experience with this technology, but want to help. Here is some official documentation, that might be useful: oficial doc more specific

If you have some uncommon issue, tell about it, maybe any error, or whatever.. I would try my best to help)

Upd1 : Solr can only maintain a 'flat' representation of the data. What you weretrying to do is not really possible. There are a number of workarounds, such as using dynamic fields and using a solr join to link multiple data sets.

Speking about a deep nesting ? I've found such an example of work around. If you had something like that:

 "docs": [
      {
        "name": "Product Name",
        "categories": [
          {
            "name": "Category 1",
            "priority": 8
          },
          {
            "name": "Category 2",
            "priority": 6
          }
          ...
        ]
      },

You have to modify it like that to make it not deeply nested :

 "docs": [
    {
      name: "Sample Product"
      categories: [
      {
        priority_category: "9_Category 1",
      },
      {
        priority_category: "5_Category 2",
      }
      ...
      ]
    },

So, you've done something similar, check if there are any errors anywhere

Upvotes: 1

Related Questions