简体   繁体   中英

Apache Solr 7.4 : Nesting with “_childDocuments_” not working, the document is still flat

My use case is this : I have a Parent -> Children -> GrandChildren hierarchy.

I would like to ingest documents as nested and would like to do BlockJoin queries to retrieve all grandchildren of a particular parent, all children of particular parent etc.

I have defined the appropriate fields in the schema (using curl) and copy fields and field-types as required by my application. I have also defined "text" as a copy field for everything as I have to support random searches.

I have defined the document to ingest as follows :

{

"id": "3443",

"path": "1.employee",

"employeeId": 3443,

"employeeName": "Tom",

"employeeCounty": "Maricopa",

"_childDocuments_": [{

    "id": "3443.54545454",

    "path": "2.employee.assets",

    "assetId": 54545454,

    "assetName": "Lenovo",

    "assetType": "Laptop",

    "_childDocuments_": [{

        "id": "3443.54545454.5764646",

        "path": "3.employee.assets.assetType",

        "processorId": 5764646,

        "processorType": "Intel core i7"
    }]
}]

}

Now when I query using the Admin UI, I am getting the following flattened out object, also block join queries don't work as well :

 { "responseHeader":{ "status":0, "QTime":0, "params":{ "q":"*:*", "_":"1533252181415"}}, "response":{"numFound":1,"start":0,"docs":[ { "id":"3443", "employeeId":3443, "text":["3443", "Tom", "Maricopa"], "employeeName":"Tom", "employeeCounty":"Maricopa", "_childDocuments_.id":[3443.54545454, 3443.643534544], "_childDocuments_.path":["2.employee.assets], "_childDocuments_.assetId":[54545454, 643534544], "_childDocuments_.assetName":["Lenovo"],

What am I missing? How can I make Solr process the nested documents like they are supposed to be rather than flattening them out?

Any help is appreciated.

Found the solution. I was using the wrong URL to post. I was using http://localhost:8983/solr/my-core/update/json/docs

Instead I should just use http://localhost:8983/solr/my-core/update Because I am already formatting the doc in Solr format and Solr neednt do any special processing to index it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM