API Methods
Elastics exposes the full elasticsearch API as own class methods. You will need to use them directly only for advanced usage, however Elastics uses them internally and creates them with just a few lines of yaml. Indeed they are just generated by Generic Templates (see Elastics Generic Templates).
The naming of these methods tries to conform with the original elasticsearch documentation, and adds a few aliases for convenience.
As any template-generated method, they accept a list of variables (hashes) for interpolation (see Variables and Interpolation). This documentation reports the underlying templates and the usage examples complete with all the accepted variable, for completeness. Please, notice that you can omit variables that have defaults.
When an API has flags/parameters, you can pass them as the :params
variable; when it has structured data you can pass it as the :data
variable.
Notice: you can get the updated full reference and usage example of these methods also in the console at any time, by just writing
Elastics.doc
(for the full API) orElastics.doc :create_index, :get_index_mapping, ...
(for specific methods). You can also get only the usage withElastics.usage
, and search for some pattern or string (part of any API method) withElastics.find('get')
.
This document is updated to elasticsearch version 1.7.3
Document API
Index API | |
---|---|
Elastics.store
|
Template
Usage
Aliases put_store
|
Elastics.post_store
|
Template
Usage
Aliases put_store
|
Get API | |
Elastics.get
|
Template
Usage
|
Elastics.get_source
|
Template
Usage
|
Delete API | |
Elastics.delete
|
Template
Usage
Aliases remove
|
Update API | |
Elastics.update
|
Template
Usage
|
Multi Get API | |
Elastics.multi_get_ids
|
Template
Usage
Aliases multi_get
|
Elastics.multi_get_docs
|
Template
Usage
Aliases multi_get
|
Bulk API | |
Elastics.post_bulk_string
|
Template
Usage
Aliases bulk
|
Term Vectors | |
Elastics.termvector
|
Template
Usage
|
Multi Termvectors API | |
Elastics.multi_termvectors
|
Template
Usage
|
Indices API
Create Index | |
---|---|
Elastics.put_index
|
Template
Usage
Aliases create_index
|
Elastics.post_index
|
Template
Usage
Aliases create_index
|
Delete Index | |
Elastics.delete_index
|
Template
Usage
|
Get Index | |
Elastics.get_index
|
Template
Usage
|
Indices Exists | |
Elastics.indices_exists
|
Template
Usage
Aliases index_exists
exist?
|
Open/Close Index | |
Elastics.close_index
|
Template
Usage
|
Elastics.open_index
|
Template
Usage
|
Put Mappings | |
Elastics.put_index_mapping
|
Template
Usage
Aliases put_mappings
|
Get Mappings | |
Elastics.get_index_mapping
|
Template
Usage
|
Get Field Mappings | |
Elastics.get_field_mapping
|
Template
Usage
|
Types Exists | |
Elastics.types_exists
|
Template
Usage
Aliases type_exists
|
Delete Mappings | |
Elastics.delete_index_mapping
|
Template
Usage
|
Index Aliases | |
Elastics.get_index_aliases
|
Template
Usage
|
Elastics.post_index_aliases
|
Template
Usage
|
Elastics.delete_index_alias
|
Template
Usage
|
Elastics.get_index_alias
|
Template
Usage
|
Elastics.put_index_alias
|
Template
Usage
|
Update Indices Settings | |
Elastics.update_index_settings
|
Template
Usage
Aliases put_index_settings
|
Get Indices Settings | |
Elastics.get_index_settings
|
Template
Usage
Aliases get_settings
|
Analyze | |
Elastics.analyze_index
|
Template
Usage
|
Index Templates | |
Elastics.delete_index_template
|
Template
Usage
|
Elastics.get_index_template
|
Template
Usage
|
Elastics.index_template_exists
|
Template
Usage
|
Elastics.put_index_template
|
Template
Usage
|
Warmers | |
Elastics.delete_index_warmer
|
Template
Usage
|
Elastics.put_index_warmer
|
Template
Usage
|
Elastics.get_index_warmer
|
Template
Usage
|
Status | |
Elastics.index_status
|
Template
Usage
|
Stats | |
Elastics.index_stats
|
Template
Usage
|
Segments | |
Elastics.index_segments
|
Template
Usage
|
Recovery | |
Elastics.index_recovery
|
Template
Usage
|
Elastics.index_clearcache
|
Template
Usage
|
Flush | |
Elastics.flush_index
|
Template
Usage
|
Synced Flush | |
Elastics.synced_flush_index
|
Template
Usage
|
Refresh | |
Elastics.refresh_index
|
Template
Usage
|
Optimize | |
Elastics.optimize_index
|
Template
Usage
|
Upgrade | |
Elastics.upgrade_index
|
Template
Usage
|
Search API
Search Shards | |
---|---|
Elastics.search_shards
|
Template
Usage
|
Elastics.count
|
Template
Usage
|
Search Exists | |
Elastics.search_exists
|
Template
Usage
|
Validate | |
Elastics.validate
|
Template
Usage
|
Elastics.explain
|
Template
Usage
|
Percolator | |
Elastics.delete_percolator
|
Template
Usage
|
Elastics.percolate
|
Template
Usage
|
Elastics.percolate_count
|
Template
Usage
|
Elastics.put_percolator
|
Template
Usage
|
More Like This | |
Elastics.more_like_this
|
Template
Usage
Aliases mlt
|
Cat API
Cat API | |
---|---|
Elastics.cat
|
Template
Usage
|
Cluster API
Health | |
---|---|
Elastics.cluster_health
|
Template
Usage
|
State | |
Elastics.cluster_state
|
Template
Usage
|
Stats | |
Elastics.cluster_stats
|
Template
Usage
|
Pending Cluster Tasks | |
Elastics.cluster_pending_tasks
|
Template
Usage
|
Cluster Reroute | |
Elastics.cluster_reroute
|
Template
Usage
|
Cluster Update Settings | |
Elastics.put_cluster_settings
|
Template
Usage
|
Nodes Stats | |
Elastics.cluster_nodes_stats
|
Template
Usage
|
Nodes Info | |
Elastics.cluster_nodes_info
|
Template
Usage
|
Nodes Hot Threads | |
Elastics.cluster_nodes_hot_threads
|
Template
Usage
|
Elastics Additions
Elastics Additions | |
---|---|
Elastics.match_all
|
Not a real API method, but handy: Template
Usage
|
Elastics.search_by_id
|
Get a document without using the get API (which doesn't support fields '*') Template
Usage
|
YourClass.elastics.multi_search
|
The method allows you to do multi-searching by using multiple templates defined by your class. It takes 2 arguments. The first is a required hash with the templates names as the keys and the variable hash as the values. You can also use an array of arrays. The second is an optional hash of variables that will be used to render the Template
Usage
|
Elastics.scan_search
|
Generic implementation of the elasticsearch search_type API of type Usage
|
Elastics.scan_all
|
Specific implementation of the elasticsearch search_type API of type Usage
|
Elastics.dump_all
|
It Usage
|
Elastics.dump_one
|
It Usage
|
If you find any elasticsearch API missing from this list, please, let me know and I will add it right away (it should be just a matter of a few minutes)