简体   繁体   中英

SOLR nested entities query (Oracle SQL DIH)

I want to setup my SOLR (8.5.2) schema in such a way that I can query a parent entity and get the child entities associated with it all in the same result. For example:

{
  entityId: 1,
  entityName: "something"
  locations: [ ( <- nested entity)
   {
     locationId: 1,
     locationName: "something"
   },
   {
     locationId: 2,
     locationName "something"
   }
  ]
}

I have managed to import the data from an Oracle Database with nested entities, here's my dataconfig.xml

  <document name="entities">
    <entity name="entity"
            query="select * from LIC_ENTITIES" >
        <field column="ENT_ID" name="entityId"/>
        <field column="NOMBRE" name="entityName"/>
        
        <entity name="entity_locations" 
                child="true"
                query="select * from LIC_ENTITIES_LOCATIONS where ent_ent_id ='${entity.ENT_ID}'">
            <field column="LOC_ID" name="locationId"/>
            <field column="NOMBRE" name="locationName"/>        
        </entity>
        
    </entity>
        
  </document>

Here's the schema.xml fields configuration:

    <!-- If you don't use child/nested documents, then you should remove the next two fields:  -->
    <!-- for nested documents (minimal; points to root document) -->
    <field name="_root_" type="string" indexed="true" stored="true" docValues="false" />
    
    <!-- for nested documents (relationship tracking) -->
    <field name="_nest_path_" type="_nest_path_" indexed="true" stored="true"/>
    <fieldType name="_nest_path_" class="solr.NestPathField" />

    <field name="_text_" type="text_general" indexed="true" stored="false" multiValued="true"/>
    
    <field name="entityId" type="pint" docValues="false" indexed="true" stored="true"/>
    <field name="entityName" type="string" docValues="false" indexed="true" stored="true"/>

    <field name="locationId" type="pint" docValues="false" indexed="true" stored="true"/>
    <field name="locationName" type="string" docValues="false" indexed="true" stored="true"/>

All the data is imported and I can query it just fine, but I can't query a parent entity and get the child entities at the same time.

I've tried using the Child Transformer (eg [child parentFilter=entityId:274939]) but I get the following error:

Parent filter should not be sent when the schema is nested

I've tried using Block Join Query (eg q={:parent which="entityId.274939"}) but it only returns either the parent or the child records.

I've tried using a multi-valued field to store the child elements but it that creates a flat array making it harder to select the child elements.

I've had to create separate entities and then make the relation between them in Node by querying them separately but I wanted to simplify it by having SOLR deliviring the data already formatted the way I wanted.

Is there any way to achieve this kind of result?

unfortunately currently available DIH does not support this field and solr drop support of dih. Currently it is going in sparete project and has few comunity support.

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