- Elasticsearch Guide: other versions:
- Getting Started
- Setup
- Breaking changes
- Breaking changes in 2.0
- Removed features
- Network changes
- Multiple
path.data
striping - Mapping changes
- CRUD and routing changes
- Query DSL changes
- Search changes
- Aggregation changes
- Parent/Child changes
- Scripting changes
- Index API changes
- Snapshot and Restore changes
- Plugin and packaging changes
- Setting changes
- Stats, info, and
cat
changes - Java API changes
- Breaking changes in 2.0
- API Conventions
- Document APIs
- Search APIs
- Aggregations
- Metrics Aggregations
- Bucket Aggregations
- Children Aggregation
- Date Histogram Aggregation
- Date Range Aggregation
- Filter Aggregation
- Filters Aggregation
- Geo Distance Aggregation
- GeoHash grid Aggregation
- Global Aggregation
- Histogram Aggregation
- IPv4 Range Aggregation
- Missing Aggregation
- Nested Aggregation
- Range Aggregation
- Reverse nested Aggregation
- Sampler Aggregation
- Significant Terms Aggregation
- Terms Aggregation
- Pipeline Aggregations
- Caching heavy aggregations
- Returning only aggregation results
- Aggregation Metadata
- Indices APIs
- Create Index
- Delete Index
- Get Index
- Indices Exists
- Open / Close Index API
- Put Mapping
- Get Mapping
- Get Field Mapping
- Types Exists
- Index Aliases
- Update Indices Settings
- Get Settings
- Analyze
- Index Templates
- Warmers
- Shadow replica indices
- Indices Stats
- Indices Segments
- Indices Recovery
- Indices Shard Stores
- Clear Cache
- Flush
- Refresh
- Optimize
- Upgrade
- cat APIs
- Cluster APIs
- Query DSL
- Mapping
- Field datatypes
- Meta-Fields
- Mapping parameters
analyzer
boost
coerce
copy_to
doc_values
dynamic
enabled
fielddata
format
geohash
geohash_precision
geohash_prefix
ignore_above
ignore_malformed
include_in_all
index
index_options
lat_lon
fields
norms
null_value
position_increment_gap
precision_step
properties
search_analyzer
similarity
store
term_vector
- Dynamic Mapping
- Transform
- Analysis
- Analyzers
- Tokenizers
- Token Filters
- Standard Token Filter
- ASCII Folding Token Filter
- Length Token Filter
- Lowercase Token Filter
- Uppercase Token Filter
- NGram Token Filter
- Edge NGram Token Filter
- Porter Stem Token Filter
- Shingle Token Filter
- Stop Token Filter
- Word Delimiter Token Filter
- Stemmer Token Filter
- Stemmer Override Token Filter
- Keyword Marker Token Filter
- Keyword Repeat Token Filter
- KStem Token Filter
- Snowball Token Filter
- Phonetic Token Filter
- Synonym Token Filter
- Compound Word Token Filter
- Reverse Token Filter
- Elision Token Filter
- Truncate Token Filter
- Unique Token Filter
- Pattern Capture Token Filter
- Pattern Replace Token Filter
- Trim Token Filter
- Limit Token Count Token Filter
- Hunspell Token Filter
- Common Grams Token Filter
- Normalization Token Filter
- CJK Width Token Filter
- CJK Bigram Token Filter
- Delimited Payload Token Filter
- Keep Words Token Filter
- Keep Types Token Filter
- Classic Token Filter
- Apostrophe Token Filter
- Character Filters
- ICU Analysis Plugin
- Modules
- Index Modules
- Testing
- Glossary of terms
- Release Notes
WARNING: Version 2.0 of Elasticsearch has passed its EOL date.
This documentation is no longer being maintained and may be removed. If you are running this version, we strongly advise you to upgrade. For the latest information, see the current release documentation.
Java API changes
editJava API changes
editTransport API construction
editThe TransportClient
construction code has changed, it now uses the builder
pattern. Instead of:
Settings settings = Settings.settingsBuilder() .put("cluster.name", "myClusterName").build(); Client client = new TransportClient(settings);
Use the following:
Settings settings = Settings.settingsBuilder() .put("cluster.name", "myClusterName").build(); Client client = TransportClient.builder().settings(settings).build();
The transport client also no longer supports loading settings from config files. If you have a config file, you can load it into settings yourself before constructing the transport client:
Settings settings = Settings.settingsBuilder() .loadFromPath(pathToYourSettingsFile).build(); Client client = TransportClient.builder().settings(settings).build();
Exception are only thrown on total failure
editPreviously, many APIs would throw an exception if any shard failed to execute
the request. Now the exception is only thrown if all shards fail the request.
The responses for these APIs will always have a getShardFailures
method that
you can and should check for failures.
IndexMissingException removed.
editUse IndexNotFoundException
instead.
Automatically thread client listeners
editPreviously, the user had to set request listener threads to true
when on the
client side in order not to block IO threads on heavy operations. This proved
to be very trappy for users, and ended up creating problems that are very hard
to debug.
In 2.0, Elasticsearch automatically threads listeners that are used from the client when the client is a node client or a transport client. Threading can no longer be manually set.
Query/filter refactoring
editorg.elasticsearch.index.queries.FilterBuilders
has been removed as part of the merge of
queries and filters. These filters are now available in QueryBuilders
with the same name.
All methods that used to accept a FilterBuilder
now accept a QueryBuilder
instead.
In addition some query builders have been removed or renamed:
-
commonTerms(...)
renamed withcommonTermsQuery(...)
-
queryString(...)
renamed withqueryStringQuery(...)
-
simpleQueryString(...)
renamed withsimpleQueryStringQuery(...)
-
textPhrase(...)
removed -
textPhrasePrefix(...)
removed -
textPhrasePrefixQuery(...)
removed -
filtered(...)
removed. UsefilteredQuery(...)
instead. -
inQuery(...)
removed.
GetIndexRequest
editGetIndexRequest.features()
now returns an array of Feature Enums instead of an array of String values.
The following deprecated methods have been removed:
-
GetIndexRequest.addFeatures(String[])
- UseGetIndexRequest.addFeatures(Feature[])
instead -
GetIndexRequest.features(String[])
- UseGetIndexRequest.features(Feature[])
instead. -
GetIndexRequestBuilder.addFeatures(String[])
- UseGetIndexRequestBuilder.addFeatures(Feature[])
instead. -
GetIndexRequestBuilder.setFeatures(String[])
- UseGetIndexRequestBuilder.setFeatures(Feature[])
instead.
BytesQueryBuilder removed
editThe redundant BytesQueryBuilder has been removed in favour of the WrapperQueryBuilder internally.
TermsQueryBuilder execution removed
editThe TermsQueryBuilder#execution
method has been removed as it has no effect, it is ignored by the
corresponding parser.
ImmutableSettings removed
editUse Settings.builder()
instead of ImmutableSettings.builder()
.
InetSocketTransportAddress removed
editUse InetSocketTransportAddress(InetSocketAddress address)
instead of InetSocketTransportAddress(String, int)
.
You can create an InetSocketAddress instance with InetSocketAddress(String, int)
. For example:
new InetSocketTransportAddress(new InetSocketAddress("127.0.0.1", 0));
Request Builders refactoring
editAn action
parameter has been added to various request builders:
-
Instead of
new SnapshotsStatusRequestBuilder(elasticSearchClient)
usenew SnapshotsStatusRequestBuilder(elasticSearchClient, SnapshotsStatusAction.INSTANCE)
. -
Instead of
new CreateSnapshotRequestBuilder(elasticSearchClient)
usenew CreateSnapshotRequestBuilder(elasticSearchClient, CreateSnapshotAction.INSTANCE)
. -
Instead of
new CreateIndexRequestBuilder(elasticSearchClient, index)
usenew CreateIndexRequestBuilder(elasticSearchClient, CreateIndexAction.INSTANCE, index)
.
Shading and package relocation removed
editElasticsearch used to shade its dependencies and to relocate packages. We no longer use shading or relocation. You might need to change your imports to the original package names:
-
com.google.common
wasorg.elasticsearch.common
-
com.carrotsearch.hppc
wasorg.elasticsearch.common.hppc
-
jsr166e
wasorg.elasticsearch.common.util.concurrent.jsr166e
-
com.fasterxml.jackson
wasorg.elasticsearch.common.jackson
-
org.joda.time
wasorg.elasticsearch.common.joda.time
-
org.joda.convert
wasorg.elasticsearch.common.joda.convert
-
org.jboss.netty
wasorg.elasticsearch.common.netty
-
com.ning.compress
wasorg.elasticsearch.common.compress
-
com.github.mustachejava
wasorg.elasticsearch.common.mustache
-
com.tdunning.math.stats
wasorg.elasticsearch.common.stats
-
org.apache.commons.lang
wasorg.elasticsearch.common.lang
-
org.apache.commons.cli
wasorg.elasticsearch.common.cli.commons
On this page
- Transport API construction
- Exception are only thrown on total failure
- IndexMissingException removed.
- Automatically thread client listeners
- Query/filter refactoring
- GetIndexRequest
- BytesQueryBuilder removed
- TermsQueryBuilder execution removed
- ImmutableSettings removed
- InetSocketTransportAddress removed
- Request Builders refactoring
- Shading and package relocation removed