Grails-ElasticSearch Plugin: Conditional Indexing of domain instances
Asked Answered
G

1

6

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

Garrettgarrick answered 12/6, 2014 at 5:28 Comment(0)
I
1

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.

Inconsonant answered 14/4, 2015 at 17:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.