Search code examples
ruby-on-rails-3elasticsearchtire

Parent/Child relation in search engine index (Rails 3.2 and ElasticSearch >v1)


I am using the official gems suite of elasticsearch elasticsearch-rails, I am having really hard time trying to index a parent/child relation, and I am not sure whether my problems are in the mapping or the indexing or the querying or in all of them !! so I wont post my code snippets.

Is there a full working example of the following:

  • Mapping of both the child and parent indices
  • Indexing/Updating/Deleting of both child and parent
  • Querying an advanced query, on both indices; meaning that I need to search on the parent index with 'has_child' query, also need to search on the child index with 'has_parent' query and filter.

I found a full example using 'Tire' gem, and I copied a lot of it but still no luck and can't find the equivilant methods in elasticsearch-rails gem, please help!


Solution

  • I found this test inside the gem, which has exactly what I needed and It works !

    Posting it if someone has the same issue.