Elastic - newgeekorder/TechWiki GitHub Wiki
Installing Elastic Search
In your install directory
curl -L -O -k https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.2.tar.gz
tar -xvf elasticsearch-0.90.2.tar.gz
ln -s elasticsearch-0.90.2 elasticsearch
Optional install the elastic search servies wrapper
curl -L -k http://github.com/elasticsearch/elasticsearch-servicewrapper/tarball/master | tar -xz
mv *servicewrapper*/service elasticsearch/bin/
elasticsearch/bin/service/elasticsearch install
ln -s `readlink -f elasticsearch/bin/service/elasticsearch` /usr/local/bin/rcelasticsearch
rcelasticsearch start
Configuraiton
Create a Unique name for the node:
/elasticsearch/config/elasticsearch.yml and on line 32 edit
cluster.name: PUT-SOMETHING-UNIQUE-HERE
Ideally increase the heap size /elasticsearch/bin/service/elasticsearch.conf set.default.ES_HEAP_SIZE=1024
API
The api an be broken down by
- Index API
- Get API
- Delete API
- Update API
- Multi Get API
- Bulk API
Example Queries
- Update Updates can be performed by PUT operations or UPDATE queries
PUT v2_reference/all_xpath/filemanifestmessage
{
"xpathmapping": {
"dc:subject": "//fmns:FileManifestMessage/FileManifest/Subject",
"classification": "concat-all(//fmns:FileManifestMessage/FileManifest/Classification/Key, //fmns:FileManifestMessage/FileManifest/Classification/Value)",
"dc:identifier": "//fmns:FileManifestMessage/FileManifest/FileDetails/FileUuid",
"dc:title": "//fmns:FileManifestMessage/FileManifest/FileDetails/FileUri",
"dc:source" : "//fmns:FileManifestMessage/FileManifest/Source",
"dc:date" : "//fmns:FileManifestMessage/FileManifest/TimePeriod/Date",
"dc:coverage" : "//fmns:FileManifestMessage/FileManifest/TerritorialCoverage"
},
"xpathnsprefix": {"fmns": "http://schemas.umusic.com/umg.eai.data-lake-messages.v1"}
}
the same file can then be retrieved (without search) query
GET v2_reference/all_xpath/filemanifestmessage
- delete
DELETE resources_v22\_query
{
"query": {
"query_string": {
"query": "message_id:4c5533f0-81bc-48d7-b381-4c0872c549ff"
}
}
}
``
## Plugins
* Elastic Search [head](http://mobz.github.io/elasticsearch-head/) .. is a good tool to help view indexes and build queries

A list of other official plugins are [here](https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-plugins.html)
## ES Security
* official is [shield](https://www.elastic.co/products/shield)
* [hawk](https://github.com/hueniverse/hawk)
## Cat Api - for backup and restores
* https://github.com/Asquera/elasticsearch-introduction/blob/gh-pages/elasticsearch-1.0.md
# Scripting
Elastic has switched their default [scripting](https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html) to Groovy
## Groovy and Transform
* Elastic search can tranform/fix incoming data with the [Transform]( http://www.gridshore.nl/2014/07/26/transform-the-input-before-indexing-in-elasticsearch/) and groovy
## Links and Reference
* [Elastic Sql interface](https://github.com/NLPchina/elasticsearch-sql)
## Bulk Loading
* http://www.embulk.org/docs/