Skip to content

Commit

Permalink
Merge branch 'master' into mrjar
Browse files Browse the repository at this point in the history
* master: (35 commits)
  Move the multi-get response tests to server
  Require JDK 9 for compilation (elastic#28071)
  Revert "[Docs] Fix Java Api index administration usage (elastic#28133)"
  Revert "[Docs] Fix base directory to include for put_mapping.asciidoc"
  Added multi get api to the high level rest client.
  [Docs] Clarify numeric datatype ranges (elastic#28240)
  [Docs] Fix base directory to include for put_mapping.asciidoc
  Open engine should keep only starting commit (elastic#28228)
  [Docs] Fix Java Api index administration usage (elastic#28133)
  Fix eclipse build. (elastic#28236)
  Never return null from Strings.tokenizeToStringArray (elastic#28224)
  Fallback to TransportMasterNodeAction for cluster health retries (elastic#28195)
  [Docs] Changes to ingest.asciidoc (elastic#28212)
  TEST: Update logging for testAckedIndexing
  [GEO] Add WKT Support to GeoBoundingBoxQueryBuilder
  Painless: Add whitelist extensions (elastic#28161)
  Fix daitch_mokotoff phonetic filter to use the dedicated Lucene filter (elastic#28225)
  Avoid doing redundant work when checking for self references. (elastic#26927)
  Fix casts in HotThreads. (elastic#27578)
  Ignore the `-snapshot` suffix when comparing the Lucene version in the build and the docs. (elastic#27927)
  ...
  • Loading branch information
jasontedor committed Jan 16, 2018
2 parents f80363e + e5a6984 commit 57972df
Show file tree
Hide file tree
Showing 210 changed files with 2,190 additions and 690 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ subprojects {
"org.elasticsearch:rest-api-spec:${version}": ':rest-api-spec',
"org.elasticsearch:elasticsearch:${version}": ':server',
"org.elasticsearch:elasticsearch-cli:${version}": ':server:cli',
"org.elasticsearch:elasticsearch-core:${version}": ':libs:elasticsearch-core',
"org.elasticsearch:elasticsearch-nio:${version}": ':libs:elasticsearch-nio',
"org.elasticsearch.client:elasticsearch-rest-client:${version}": ':client:rest',
"org.elasticsearch.client:elasticsearch-rest-client-sniffer:${version}": ':client:sniffer',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,28 +169,24 @@ class BuildPlugin implements Plugin<Project> {
project.ext.runtimeJavaVersion = project.rootProject.ext.runtimeJavaVersion
}

/** Finds and enforces JAVA_HOME is set */
private static String findCompilerJavaHome() {
return findJavaHome(System.getenv('JAVA_HOME'), null)
}

private static String findRuntimeJavaHome(final String compilerJavaHome) {
return findJavaHome(System.getenv('RUNTIME_JAVA_HOME'), compilerJavaHome)
}

private static String findJavaHome(String maybeJavaHome, String defaultJavaHome) {
final String javaHome = maybeJavaHome ?: defaultJavaHome
final String javaHome = System.getenv('JAVA_HOME')
if (javaHome == null) {
if (System.getProperty("idea.active") != null || System.getProperty("eclipse.launcher") != null) {
// IntelliJ does not set JAVA_HOME, so we use the JDK that Gradle was run with
javaHome = Jvm.current().javaHome
return Jvm.current().javaHome
} else {
assert false
throw new GradleException("JAVA_HOME must be set to build Elasticsearch")
}
}
return javaHome
}

private static String findRuntimeJavaHome(final String compilerJavaHome) {
assert compilerJavaHome != null
return System.getenv('RUNTIME_JAVA_HOME') ?: compilerJavaHome
}

/** Finds printable java version of the given JAVA_HOME */
private static String findJavaVersionDetails(Project project, String javaHome) {
String versionInfoScript = 'print(' +
Expand Down Expand Up @@ -455,6 +451,8 @@ class BuildPlugin implements Plugin<Project> {

options.encoding = 'UTF-8'
options.incremental = true

// TODO: use native Gradle support for --release when available (cf. https://github.com/gradle/gradle/issues/2510)
options.compilerArgs << '--release' << targetCompatibilityVersion.majorVersion
}
}
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/version.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
elasticsearch = 7.0.0-alpha1
lucene = 7.2.0
lucene = 7.2.1

# optional dependencies
spatial4j = 0.6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.elasticsearch.action.bulk.BulkRequest;
import org.elasticsearch.action.delete.DeleteRequest;
import org.elasticsearch.action.get.GetRequest;
import org.elasticsearch.action.get.MultiGetRequest;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.search.ClearScrollRequest;
import org.elasticsearch.action.search.MultiSearchRequest;
Expand Down Expand Up @@ -312,6 +313,15 @@ static Request get(GetRequest getRequest) {
return new Request(HttpGet.METHOD_NAME, endpoint, parameters.getParams(), null);
}

static Request multiGet(MultiGetRequest multiGetRequest) throws IOException {
Params parameters = Params.builder();
parameters.withPreference(multiGetRequest.preference());
parameters.withRealtime(multiGetRequest.realtime());
parameters.withRefresh(multiGetRequest.refresh());
HttpEntity entity = createEntity(multiGetRequest, REQUEST_BODY_CONTENT_TYPE);
return new Request(HttpGet.METHOD_NAME, "/_mget", parameters.getParams(), entity);
}

static Request index(IndexRequest indexRequest) {
String method = Strings.hasLength(indexRequest.id()) ? HttpPut.METHOD_NAME : HttpPost.METHOD_NAME;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.action.get.GetRequest;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.action.get.MultiGetRequest;
import org.elasticsearch.action.get.MultiGetResponse;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.action.main.MainRequest;
Expand Down Expand Up @@ -289,6 +291,25 @@ public final void getAsync(GetRequest getRequest, ActionListener<GetResponse> li
performRequestAsyncAndParseEntity(getRequest, Request::get, GetResponse::fromXContent, listener, singleton(404), headers);
}

/**
* Retrieves multiple documents by id using the Multi Get API
*
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.html">Multi Get API on elastic.co</a>
*/
public final MultiGetResponse multiGet(MultiGetRequest multiGetRequest, Header... headers) throws IOException {
return performRequestAndParseEntity(multiGetRequest, Request::multiGet, MultiGetResponse::fromXContent, singleton(404), headers);
}

/**
* Asynchronously retrieves multiple documents by id using the Multi Get API
*
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.html">Multi Get API on elastic.co</a>
*/
public void multiGetAsync(MultiGetRequest multiGetRequest, ActionListener<MultiGetResponse> listener, Header... headers) {
performRequestAsyncAndParseEntity(multiGetRequest, Request::multiGet, MultiGetResponse::fromXContent, listener,
singleton(404), headers);
}

/**
* Checks for the existence of a document. Returns true if it exists, false otherwise
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.action.get.GetRequest;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.action.get.MultiGetRequest;
import org.elasticsearch.action.get.MultiGetResponse;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.action.update.UpdateRequest;
Expand Down Expand Up @@ -238,6 +240,64 @@ public void testGet() throws IOException {
}
}

public void testMultiGet() throws IOException {
{
MultiGetRequest multiGetRequest = new MultiGetRequest();
multiGetRequest.add("index", "type", "id1");
multiGetRequest.add("index", "type", "id2");
MultiGetResponse response = execute(multiGetRequest, highLevelClient()::multiGet, highLevelClient()::multiGetAsync);
assertEquals(2, response.getResponses().length);

assertTrue(response.getResponses()[0].isFailed());
assertNull(response.getResponses()[0].getResponse());
assertEquals("id1", response.getResponses()[0].getFailure().getId());
assertEquals("type", response.getResponses()[0].getFailure().getType());
assertEquals("index", response.getResponses()[0].getFailure().getIndex());
assertEquals("Elasticsearch exception [type=index_not_found_exception, reason=no such index]",
response.getResponses()[0].getFailure().getFailure().getMessage());

assertTrue(response.getResponses()[1].isFailed());
assertNull(response.getResponses()[1].getResponse());
assertEquals("id2", response.getResponses()[1].getId());
assertEquals("type", response.getResponses()[1].getType());
assertEquals("index", response.getResponses()[1].getIndex());
assertEquals("Elasticsearch exception [type=index_not_found_exception, reason=no such index]",
response.getResponses()[1].getFailure().getFailure().getMessage());
}

String document = "{\"field\":\"value1\"}";
StringEntity stringEntity = new StringEntity(document, ContentType.APPLICATION_JSON);
Response r = client().performRequest("PUT", "/index/type/id1", Collections.singletonMap("refresh", "true"), stringEntity);
assertEquals(201, r.getStatusLine().getStatusCode());

document = "{\"field\":\"value2\"}";
stringEntity = new StringEntity(document, ContentType.APPLICATION_JSON);
r = client().performRequest("PUT", "/index/type/id2", Collections.singletonMap("refresh", "true"), stringEntity);
assertEquals(201, r.getStatusLine().getStatusCode());

{
MultiGetRequest multiGetRequest = new MultiGetRequest();
multiGetRequest.add("index", "type", "id1");
multiGetRequest.add("index", "type", "id2");
MultiGetResponse response = execute(multiGetRequest, highLevelClient()::multiGet, highLevelClient()::multiGetAsync);
assertEquals(2, response.getResponses().length);

assertFalse(response.getResponses()[0].isFailed());
assertNull(response.getResponses()[0].getFailure());
assertEquals("id1", response.getResponses()[0].getId());
assertEquals("type", response.getResponses()[0].getType());
assertEquals("index", response.getResponses()[0].getIndex());
assertEquals(Collections.singletonMap("field", "value1"), response.getResponses()[0].getResponse().getSource());

assertFalse(response.getResponses()[1].isFailed());
assertNull(response.getResponses()[1].getFailure());
assertEquals("id2", response.getResponses()[1].getId());
assertEquals("type", response.getResponses()[1].getType());
assertEquals("index", response.getResponses()[1].getIndex());
assertEquals(Collections.singletonMap("field", "value2"), response.getResponses()[1].getResponse().getSource());
}
}

public void testIndex() throws IOException {
final XContentType xContentType = randomFrom(XContentType.values());
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.elasticsearch.action.bulk.BulkShardRequest;
import org.elasticsearch.action.delete.DeleteRequest;
import org.elasticsearch.action.get.GetRequest;
import org.elasticsearch.action.get.MultiGetRequest;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.search.ClearScrollRequest;
import org.elasticsearch.action.search.MultiSearchRequest;
Expand Down Expand Up @@ -147,6 +148,59 @@ public void testGet() {
getAndExistsTest(Request::get, "GET");
}

public void testMultiGet() throws IOException {
Map<String, String> expectedParams = new HashMap<>();
MultiGetRequest multiGetRequest = new MultiGetRequest();
if (randomBoolean()) {
String preference = randomAlphaOfLength(4);
multiGetRequest.preference(preference);
expectedParams.put("preference", preference);
}
if (randomBoolean()) {
multiGetRequest.realtime(randomBoolean());
if (multiGetRequest.realtime() == false) {
expectedParams.put("realtime", "false");
}
}
if (randomBoolean()) {
multiGetRequest.refresh(randomBoolean());
if (multiGetRequest.refresh()) {
expectedParams.put("refresh", "true");
}
}

int numberOfRequests = randomIntBetween(0, 32);
for (int i = 0; i < numberOfRequests; i++) {
MultiGetRequest.Item item =
new MultiGetRequest.Item(randomAlphaOfLength(4), randomAlphaOfLength(4), randomAlphaOfLength(4));
if (randomBoolean()) {
item.routing(randomAlphaOfLength(4));
}
if (randomBoolean()) {
item.parent(randomAlphaOfLength(4));
}
if (randomBoolean()) {
item.storedFields(generateRandomStringArray(16, 8, false));
}
if (randomBoolean()) {
item.version(randomNonNegativeLong());
}
if (randomBoolean()) {
item.versionType(randomFrom(VersionType.values()));
}
if (randomBoolean()) {
randomizeFetchSourceContextParams(item::fetchSourceContext, new HashMap<>());
}
multiGetRequest.add(item);
}

Request request = Request.multiGet(multiGetRequest);
assertEquals("GET", request.getMethod());
assertEquals("/_mget", request.getEndpoint());
assertEquals(expectedParams, request.getParameters());
assertToXContentBody(multiGetRequest, request.getEntity());
}

public void testDelete() {
String index = randomAlphaOfLengthBetween(3, 10);
String type = randomAlphaOfLengthBetween(3, 10);
Expand Down
1 change: 1 addition & 0 deletions client/rest/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ forbiddenApisTest {
}

// JarHell is part of es server, which we don't want to pull in
// TODO: Not anymore. Now in elasticsearch-core
jarHell.enabled=false

namingConventions {
Expand Down
1 change: 1 addition & 0 deletions client/sniffer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ dependencyLicenses {
}

// JarHell is part of es server, which we don't want to pull in
// TODO: Not anymore. Now in elasticsearch-core
jarHell.enabled=false

namingConventions {
Expand Down
1 change: 1 addition & 0 deletions client/test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ forbiddenApisTest {
}

// JarHell is part of es server, which we don't want to pull in
// TODO: Not anymore. Now in elasticsearch-core
jarHell.enabled=false

// TODO: should we have licenses for our test deps?
Expand Down
2 changes: 1 addition & 1 deletion distribution/bwc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ if (project.hasProperty('bwcVersion')) {
task buildBwcVersion(type: Exec) {
dependsOn checkoutBwcBranch, writeBuildMetadata
workingDir = checkoutDir
if (project.rootProject.ext.runtimeJavaVersion == JavaVersion.VERSION_1_8 && ["5.6", "6.1"].contains(bwcBranch)) {
if (project.rootProject.ext.runtimeJavaVersion == JavaVersion.VERSION_1_8 && ["5.6", "6.0", "6.1"].contains(bwcBranch)) {
/*
* If runtime Java home is set to JDK 8 and we are building branches that are officially built with JDK 8, push this to JAVA_HOME for
* these builds.
Expand Down
4 changes: 2 additions & 2 deletions docs/Versions.asciidoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
:version: 7.0.0-alpha1
:major-version: 7.x
:lucene_version: 7.2.0
:lucene_version_path: 7_2_0
:lucene_version: 7.2.1
:lucene_version_path: 7_2_1
:branch: master
:jdk: 1.8.0_131
:jdk_major: 8
Expand Down
4 changes: 2 additions & 2 deletions docs/painless/painless-types.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ to floating point types.
| int | explicit | explicit | explicit | | implicit | implicit | implicit
| long | explicit | explicit | explicit | explicit | | implicit | implicit
| float | explicit | explicit | explicit | explicit | explicit | | implicit
| float | explicit | explicit | explicit | explicit | explicit | explicit |
| double | explicit | explicit | explicit | explicit | explicit | explicit |
|====


Expand Down Expand Up @@ -376,7 +376,7 @@ cast would normally be required between the non-def types.
def x; // Declare def variable x and set it to null
x = 3; // Set the def variable x to the literal 3 with an implicit
// cast from int to def
double a = x; // Declare double variable y and set it to def variable x,
double a = x; // Declare double variable a and set it to def variable x,
// which contains a double
int b = x; // ERROR: Results in a run-time error because an explicit cast is
// required to cast from a double to an int
Expand Down
25 changes: 13 additions & 12 deletions docs/reference/ingest.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,27 @@

[partintro]
--
You can use ingest node to pre-process documents before the actual indexing takes place.
This pre-processing happens by an ingest node that intercepts bulk and index requests, applies the
transformations, and then passes the documents back to the index or bulk APIs.
Use an ingest node to pre-process documents before the actual document indexing happens.
The ingest node intercepts bulk and index requests, it applies transformations, and it then
passes the documents back to the index or bulk APIs.

You can enable ingest on any node or even have dedicated ingest nodes. Ingest is enabled by default
on all nodes. To disable ingest on a node, configure the following setting in the `elasticsearch.yml` file:
All nodes enable ingest by default, so any node can handle ingest tasks. You can also create
dedicated ingest nodes. To disable ingest for a node, configure the following setting in the
elasticsearch.yml file:

[source,yaml]
--------------------------------------------------
node.ingest: false
--------------------------------------------------

To pre-process documents before indexing, you <<pipeline,define a pipeline>> that specifies
a series of <<ingest-processors,processors>>. Each processor transforms the document in some way.
For example, you may have a pipeline that consists of one processor that removes a field from
the document followed by another processor that renames a field. Configured pipelines are then stored
in the <<cluster-state,cluster state>>.
To pre-process documents before indexing, <<pipeline,define a pipeline>> that specifies a series of
<<ingest-processors,processors>>. Each processor transforms the document in some specific way. For example, a
pipeline might have one processor that removes a field from the document, followed by
another processor that renames a field. The <<cluster-state,cluster state>> then stores
the configured pipelines.

To use a pipeline, you simply specify the `pipeline` parameter on an index or bulk request to
tell the ingest node which pipeline to use. For example:
To use a pipeline, simply specify the `pipeline` parameter on an index or bulk request. This
way, the ingest node knows which pipeline to use. For example:

[source,js]
--------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions docs/reference/mapping/types/numeric.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ The following numeric types are supported:
`integer`:: A signed 32-bit integer with a minimum value of +-2^31^+ and a maximum value of +2^31^-1+.
`short`:: A signed 16-bit integer with a minimum value of +-32,768+ and a maximum value of +32,767+.
`byte`:: A signed 8-bit integer with a minimum value of +-128+ and a maximum value of +127+.
`double`:: A double-precision 64-bit IEEE 754 floating point number.
`float`:: A single-precision 32-bit IEEE 754 floating point number.
`half_float`:: A half-precision 16-bit IEEE 754 floating point number.
`double`:: A double-precision 64-bit IEEE 754 floating point number, restricted to finite values.
`float`:: A single-precision 32-bit IEEE 754 floating point number, restricted to finite values.
`half_float`:: A half-precision 16-bit IEEE 754 floating point number, restricted to finite values.
`scaled_float`:: A floating point number that is backed by a `long`, scaled by a fixed `double` scaling factor.

Below is an example of configuring a mapping with numeric fields:
Expand Down
Loading

0 comments on commit 57972df

Please sign in to comment.