Royal
Royal

Reputation: 21

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 (e.g [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 (e.g 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?

Upvotes: 2

Views: 333

Answers (1)

Halis Yılboğa
Halis Yılboğa

Reputation: 900

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.

Upvotes: 0

Related Questions