Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grails-ElasticSearch Plugin: Conditional Indexing of domain instances

I am using Grails-ElasticSearch Plugin(0.0.2.5). I want to add a constraint to my domain instances before it is indexed in ElasticSearch.

Example:- I have a domain class A with a field 'status', i want to add an abstraction between Database and ElasticSearch i.e, all the instances should be populated in the Database but instances with ACTIVE status should be sent to elasticsearch.

Please suggest if this is possible?

Thanks, Karan

like image 655
Karan Malhotra Avatar asked Jun 12 '14 05:06

Karan Malhotra


1 Answers

The simplest approach is to add all the records in the index, and then query using a Filtered Query using a filter like term("status","active"). Since the filtered query just clean all the non matching results before calculating the scores, it should not affect the performance in a significant way. A little more complex approach is to fork the repo and add an specific interceptor property.

like image 145
nan-ead Avatar answered Sep 22 '22 03:09

nan-ead