1

I indexed data in solr with 4 level data (nested), My entities are Products, Category, ProductAttribute and ProductAttributeValue.

I'm using DIH for indexing data.

My data structure is

Type: Product
--  Type: Category
--  Type: ProductAttribute
--  --  Type: ProductAttributeValue
--  --  Type: ProductAttributeValue

Here is 3 levels data, might be there possible for more level.

I'm executing below query for fetch document.

    http://localhost:8983/solr/MYCORE/select?q={!parent which="Type:product"}&fl=id,Type,Title,[child parentFilter=Type:Product]&wt=json

and I'm getting below result.

{
"numFound":2,"start":0,"docs":
[
      {
        "id":"p1",
        "Type":"Product",
        "Title":"Build your own computer",
        "_childDocuments_":
        [
            {
              "id":"c2_p1",
              "Path":2,
              "PathNew":"2.Product.Category",
              "Type":"Category",
              "CatName":"Desktops",
              "MetaKeywords":"Desktops",
              "MetaKeywords_str":"Desktops",
              "Type_str":"category",
              "_version_":1606520999021379584,
              "CatName_str":"Desktops",
              "PathNew_str":"2.Product.Category"
            },
            {
                    "id":"pa4_p1",
                    "Path":2,
                    "PathNew":"2.Product.ProductAttribute",
                    "Type":"productAttribute",
                    "PAName":"HDD",
                    "Type_str":"productAttribute",
                    "_version_":1606520999021379584,
                    "PAName_str":"HDD",
                    "PathNew_str":"2.Product.ProductAttribute"
            },
            {
              "id":"pav6_pa4_p1",
              "Path":3,
              "PathNew":"3.Product.ProductAttribute.ProductAttributeValue",
              "Type":"ProductAttributeValue",
              "PAVName":"320 GB",
              "Type_str":"ProductAttributeValue",
              "_version_":1606520999021379584,
              "PathNew_str":"3.Product.ProductAttribute.ProductAttributeValue",
              "PAVName_str":"320 GB"
            },
            {
              "id":"pav7_pa4_p1",
              "Path":3,
              "PathNew":"3.Product.ProductAttribute.ProductAttributeValue",
              "Type":"ProductAttributeValue",
              "PAVName":"400 GB",
              "Type_str":"ProductAttributeValue",
              "_version_":1606520999021379584,
              "PathNew_str":"3.Product.ProductAttribute.ProductAttributeValue",
              "PAVName_str":"400 GB"
            }
        ]
    }
]       
}

This result display nested structure till level 2, not after that.

but I want to display response with 3 level(also for n level) nested.

{
    "numFound":2,"start":0,"docs":
    [
          {
            "id":"p1",
            "Type":"Product",
            "Title":"Build your own computer",
            "_childDocuments_":
            [
                {
                  "id":"c2_p1",
                  "Path":2,
                  "PathNew":"2.Product.Category",
                  "Type":"Category",
                  "CatName":"Desktops",
                  "MetaKeywords":"Desktops",
                  "MetaKeywords_str":"Desktops",
                  "Type_str":"category",
                  "_version_":1606520999021379584,
                  "CatName_str":"Desktops",
                  "PathNew_str":"2.Product.Category"
                },
                {
                    "id":"pa4_p1",
                    "Path":2,
                    "PathNew":"2.Product.ProductAttribute",
                    "Type":"productAttribute",
                    "PAName":"HDD",
                    "Type_str":"productAttribute",
                    "_version_":1606520999021379584,
                    "PAName_str":"HDD",
                    "PathNew_str":"2.Product.ProductAttribute",
                    "_childDocuments_": 
                    [
                        {
                            "id":"pav6_pa4_p1",
                            "Path":3,
                            "PathNew":"3.Product.ProductAttribute.ProductAttributeValue",
                            "Type":"ProductAttributeValue",
                            "PAVName":"320 GB",
                            "Type_str":"ProductAttributeValue",
                            "_version_":1606520999021379584,
                            "PathNew_str":"3.Product.ProductAttribute.ProductAttributeValue",
                            "PAVName_str":"320 GB"
                        },
                        {
                            "id":"pav7_pa4_p1",
                            "Path":3,
                            "PathNew":"3.Product.ProductAttribute.ProductAttributeValue",
                            "Type":"ProductAttributeValue",
                            "PAVName":"400 GB",
                            "Type_str":"ProductAttributeValue",
                            "_version_":1606520999021379584,
                            "PathNew_str":"3.Product.ProductAttribute.ProductAttributeValue",
                            "PAVName_str":"400 GB"  
                        }
                    ]
                }   
            ]   
        }
    ]
}

I tried with different queries but not get any luck. Any help will be appreciated.

Raju Paladiya
  • 778
  • 2
  • 12
  • 35

0 Answers0