(Quick Reference)

4 Indexing - Reference Documentation

Authors: Noam Y. Tenne, Manuarii Stein, Stephane Maldini, Serge P. Nekoval, Marcos Carceles

Version: 0.0.4.6

4 Indexing

With its default configuration (with the disableAutoIndex configuration key set to false), the plugin is indexing automatically any searchable domains when GORM/Hibernate do a save or an update in the database. It also delete automatically from the index any document corresponding to a domain that is deleted from the database. You normally shouldn't have to worry about indexing, but sometimes you may have to do it by yourself, for example on dirty domain object that you may not want to save right now.

The plugin is providing a few injected methods in the domain or in the ElasticSearchService to allow that.

Index examples

// Index all searchable instances
elasticSearchService.index()

// Index a specific domain instance MyDomain md = new MyDomain(value:'that') md.save() elasticSearchService.index(md)

// Index a collection of domain instances def ds = [new MyDomain(value:'that'), new MyOtherDomain(name:'this'), new MyDomain(value:'thatagain')] ds*.save() elasticSearchService.index(ds)

// Index all instances of the specified domain class elasticSearchService.index(MyDomain) elasticSearchService.index(class:MyDomain) elasticSearchService.index(MyDomain, MyOtherDomain) elasticSearchService.index([MyDomain, MyOtherDomain])

Unindex examples

// Unindex all searchable instances
elasticSearchService.unindex()

// Unindex a specific domain instance MyDomain md = new MyDomain(value:'that') md.save() elasticSearchService.unindex(md)

// Unindex a collection of domain instances def ds = [new MyDomain(value:'that'), new MyOtherDomain(name:'this'), new MyDomain(value:'thatagain')] ds*.save() elasticSearchService.unindex(ds)

// Unindex all instances of the specified domain class elasticSearchService.unindex(MyDomain) elasticSearchService.unindex(class:MyDomain) elasticSearchService.unindex(MyDomain, MyOtherDomain) elasticSearchService.unindex([MyDomain, MyOtherDomain])