Solr以n个级别和构面嵌套显示文档

时间:2018-07-21 08:05:24

标签: solr nested solr-query-syntax

我用4级数据(嵌套)在solr中建立了索引数据, 我的实体是商品,类别,商品属性和商品属性值。

我正在使用DIH索引数据。

我的数据结构是

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

这里有3个级别的数据,可能有可能提供更多级别。

我正在执行以下查询以获取文档。

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

,我的成绩低于预期。

{
"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"
            }
        ]
    }
]       
}

此结果显示嵌套结构,直到第2级为止。

但是我想显示嵌套了3级(也适用于n级)的响应。

{
    "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"  
                        }
                    ]
                }   
            ]   
        }
    ]
}

我尝试了不同的查询,但是没有任何运气。 任何帮助将不胜感激。

0 个答案:

没有答案