How to fetch hierarchical data using elastic search


(Preeti) #1

I want to fetch hierarchical data using elastic search
I have tried 'has_parent' ,'has_child' and 'term- aggregation' but it is returning hierarchy only up to 1 level. But I want to get complete hierarchy for specific offer.

I have an index of type ‘offers’.

Let’s say it contains below documents as described below:

Each offer is being referred by another offer and that offer is again being referred by an another offer. So on.
Ex: Offer_A is being referred by offer_B , Offer_B is being referred by Offer_C and Offer_D this may go to any level

{
     “id”:  “offer_A”,
      “dependsOnOffer” :[
                   “offer_X”     
         ]
}


{
     “id”:  “offer_B”,
      “dependsOnOffer” :[
                   “offer_A”  
         ]
}


{
     “id”:  “offer _C”,
      “dependsOnOffer” :[
                   “offer_B”     
         ]
}

	 
{
     “id”:  “offer_D”,
      “dependsOnOffer” :[
                   “offer_B”     
         ]
}

Desired Output :
When I am looking for offer_A and want to fetch all of its depending on offers
Then It should return
Offer_B , Offer_C , Offer_D

Please guide us how can we achieve this requirement to be fulfilled. Thanks in Advance !!!


(Preeti) #2

Is there any update on this issue ?
Please help to resolve it


(Akib Ali) #3

@dadoonet Could you pleas help here.


(David Pilato) #4

No I don't think I can.

I'd suggest to provide a full recreation script as described in About the Elasticsearch category. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.


(system) closed #5

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.