(Quick Reference)
2 Configuration - Reference Documentation
Authors: Noam Y. Tenne, Manuarii Stein, Stephane Maldini, Serge P. Nekoval, Marcos Carceles
Version: 0.0.4.6
2 Configuration
The plugin provide a default configuration, but you may add your own settings in your
Config.groovy script.
Client mode
You can set the plugin in 3 different modes, detailed on the
official ElasticSearch doc.
The mode is defined with the following config key:
elasticSearch.client.mode = '<mode>'
Possible values:
Value | Description |
---|
node | The plugin create its own node and join the ElasticSearch cluster as a client node (node.client = true ). This setting requires that you have an ElasticSearch instance running and available on your network (use the discovery feature) |
dataNode | The plugin create its own node and join the ElasticSearch cluster as a node that can hold data. This setting requires that you have an ElasticSearch instance running and available on your network (use the discovery feature) |
local | The plugin create its own local (to the JVM) node. Does not require any running ElasticSearch instance. Useful for development or testing. |
transport | The plugin create a transport client that will connect to a remote ElasticSearch instance without joining the cluster. |
"Transport" mode needs you to provide the host address and port. You can define one or multiple hosts with the following config key:
elasticSearch.client.hosts = [
[host:'192.168.0.3', port:9300],
[host:'228.168.0.4', port:9300]
]
If no host is defined,
localhost:9300
will be used by the transport client.
Mapping Migration properties
Define the application's behaviour when a conflict is found while installing Elasticsearch mappings on startup. For a detailed explanation, see Mapping Migrations.
elasticSearch.migration.strategy
Defines the behaviour to follow if an error occurs on startup when the application is installing new mappings on ElasticSearch due to conflicting mappings.
Possible value | Description |
---|
'none' | No changes on the indices or mappings will happen, the merge problem will be logged and a MappingException will be thrown. |
'delete' | The conflicting mapping will be deleted (along with all indexed content of that type) and replaced with a new mapping. Deleted content can be automatically reindexed on startup by using this in combination the elasticSearch.bulkIndexOnStartup config option |
'alias' | Applies Elasticsearch recommended approach for migrating conflicting mappings. A new numbered index will be created (<indexName>_vX ) where new mappings will installed for all the types included on the original index. An Elasticsearch alias called <indexName> will point to the new index. As content won't be available on the new index, content can be automcatically reindexedon startup by using this in combination the elasticSearch.bulkIndexOnStartup config option. It is recommended to set elasticSearch.aliasReplacesIndex to deal with potential index/alias conflicts. |
The default is
'alias'
.
elasticSearch.migration.aliasReplacesIndex
Deals with a special conflict case using the
'alias'
strategy. When the
'alias'
migration strategy is chosen and there's a mapping conflict on an index, defines whether to replace the index with a versioned index (
<indexName>_vX
) and an alias (
<indexName>
). This is required when applying the alias strategy on top of existing indices for the first time as indices cannot be renamed (from
<indexName>
to
<indexName>_vX
) and an alias cannot exist with the same name as an index.
Possible value | Description |
---|
true | The index and it's content will be deleted and a versioned index and an alias will be created. Deleted content can be automatically reindexed on startup by using this in combination the elasticSearch.bulkIndexOnStartup config option |
false | Falls back to the 'none' strategy. Event will be logged and a MappingException will be thrown. |
The default is
true
.
elasticSearch.migration.disableAliasChange
In some cases the developer may prefer not to upgrade the alias to the new version of the index until some other tasks are performed. This allows them to disable automatically pointing the alias to a new version of the index when this is created. Aliases can be changed later on manually or programatically using
elasticSearchAdminService
Possible value | Description |
---|
false | Standard behaviour |
true | Prevents the aliases to be changed to point to a new index |
The default is
false
.
Others properties
elasticSearch.datastoreImpl
Only required when enabling the auto-index feature.
This property specifies which GORM datastore implementation should be watched for storage events.
The value should be the name of the datastore bean as it is configured in the Spring context; some possible values:
Value | Description |
---|
mongoDatastore | The name of the MongoDB datastore bean. |
hibernateDatastore | The name of the Hibernate datastore bean. |
elasticSearch.bootstrap.config.file
When using then plugin to construct a local node, the default Elasticsearch configuration is used by default.
If you use a modified Elasticsearch configuration, you can use this property to specify the location of the file (as an application resource).
elasticSearch.bootstrap.transportSettings.file
When choosing transport mode this configuration will be used to set up the TransportClient settings (used by some cloud providers).
elasticSearch.client.transport.sniff
Only usable in with a transport client.
Allows to sniff the rest of the cluster, and add those into its list of machines to use.
In this case, the ip addresses used will be the ones that the other nodes were started with (the “publish” address)
elasticSearch.cluster.name
The name of the cluster for the client to join.
elasticSearch.date.formats
List of date formats used by the JSON unmarshaller to parse any date field properly.
Note : future version of the plugin may change how formats are manipulated.
elasticSearch.defaultExcludedProperties
List of domain class properties to automatically ignore (will not be indexed) if their name match one of those.
This will apply to both the default-mapped domain class, with the static
searchable
property set to "true", and when using closure mapping.
To override this setting on a specific class, it can be added to the
only
property of the
searchable
closure.
elasticSearch.disableAutoIndex
A boolean determining if the plugin should reflect any database save/update/delete automatically on the indices.
Default to
false
.
elasticSearch.bulkIndexOnStartup
Determines whether the application should launch a bulk index operation upon startup.
Possible value | Description |
---|
false | No indexing will happen on startup. |
true | All content will be indexed on startup. |
'deleted' | This value is related to the mapping migration strategy choosen. If any migration is required and any content is deleted due to it, on startup only indices and mappings lost will be indexed. More on Mapping Migrations. |
Default to
true
.
A string indicating which ElasticSearch index should be used. If not present, will default to the package name of the domain in question.
elasticSearch.index.compound_format
Should the compound file format be used (boolean setting).
Set to
false
by default (really applicable for file system based index storage).
More details on this setting on the
ElasticSearch Documentation.
elasticSearch.index.store.type
Determine how the indices will be stored.
More details on the possible values on the
ElasticSearch Documentation.
Possible value | Description |
---|
memory | Stores the index in memory. Useful for testing. |
mmapfs | Stores the shard index on the file system (maps to Lucene MMapDirectory) using mmap. |
niofs | Stores the shard index on the file system (maps to Lucene NIOFSDirectory) and allows for multiple threads to read from the same file concurrently. |
simplefs | Stores using a plain forward implementation of file system storage (maps to Lucene SimpleFsDirectory) using random access file. |
elasticSearch.index.numberOfReplicas
Sets the number of replicas created for each shard of the index. If not present, will default to zero.
elasticSearch.gateway.type
Determine the gateway type to be used.
More details on the possible values are in the
ElasticSearch Documentation.
Using a setting of "none" (possibly in combination with index.store.type set to "memory") can be useful for tests.
elasticSearch.maxBulkRequest
Max number of requests to process at once.
Reduce this value if you have memory issue when indexing a big amount of data at once.
If this setting is not specified, 500 will be use by default.
The location of the data files of each index / shard allocated on the node.
elasticSearch.path.plugins
The location of plugin files such as native scripts. Each plugin will be contained in a subdirectory.
elasticSearch.searchableProperty.name
The name of the ElasticSearch mapping configuration property that annotates domain classes. The default is 'searchable'.
elasticSearch.includeTransients
Whether to index and search all non excluded transient properties. All explicitly included transients in
only
will be indexed regardless.
Default is
false
.
Default configuration script
Below is the default configuration loaded by the plugin (any of your settings in the Config.groovy script overwrite those).
elasticSearch {
/**
* Date formats used by the unmarshaller of the JSON responses
*/
date.formats = ["yyyy-MM-dd'T'HH:mm:ss'Z'"] /**
* Hosts for remote ElasticSearch instances.
* Will only be used with the "transport" client mode.
* If the client mode is set to "transport" and no hosts are defined, ["localhost", 9300] will be used by default.
*/
client.hosts = [
[host:'localhost', port:9300]
] /**
* Default mapping property exclusions
*
* No properties matching the given names will be mapped by default
* ie, when using "searchable = true"
*
* This does not apply for classes using mapping by closure
*/
defaultExcludedProperties = ["password"] /**
* Determines if the plugin should reflect any database save/update/delete automatically
* on the ES instance. Default to false.
*/
disableAutoIndex = false /**
* Should the database be indexed at startup.
*
* The value may be a boolean true|false.
* Indexing is always asynchronous (compared to Searchable plugin) and executed after BootStrap.groovy.
*/
bulkIndexOnStartup = true /**
* Max number of requests to process at once. Reduce this value if you have memory issue when indexing a big amount of data
* at once. If this setting is not specified, 500 will be use by default.
*/
maxBulkRequest = 500
/**
* The name of the ElasticSearch mapping configuration property that annotates domain classes. The default is 'searchable'.
*/
searchableProperty.name = 'searchable'
}environments {
development {
/**
* Possible values : "local", "node", "dataNode", "transport"
* If set to null, "node" mode is used by default.
*/
elasticSearch.client.mode = 'local'
}
test {
elasticSearch {
client.mode = 'local'
index.store.type = 'memory' // store local node in memory and not on disk
}
}
production {
elasticSearch.client.mode = 'node'
}
}