Grails-ElasticSearch Plugin: Conditional Indexing of Domain Instances

I am using the Grails-ElasticSearch plugin (0.0.2.5). I want to add a restriction to instances of my domain before it is indexed in ElasticSearch.

Example: - I have a domain class A with the "status" field, I want to add an abstraction between Database and ElasticSearch, then all 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

+6
source share
1 answer

The easiest way is to add all records to the index, and then query using a filtered query using a filter of the term ("status", "active") type. Since the filtered query simply clears all inappropriate results before calculating the scores, this should not greatly affect performance. A more sophisticated approach is to fork the repo and add a specific interceptor property.

+1
source

Source: https://habr.com/ru/post/970726/


All Articles