Commit Graph

43264 Commits

Author SHA1 Message Date
Costin Leau 6ee6bb55e2
SQL: Introduce HISTOGRAM grouping function (#36510)
Introduce Histogram grouping function for bucketing/grouping data based
 on a given range. Both date and numeric histograms are supported using
 the appropriate range declaration (numbers vs intervals).

SELECT HISTOGRAM(number, 50) AS h FROM index GROUP BY h
SELECT HISTOGRAM(date, INTERVAL 1 YEAR) AS h FROM index GROUP BY h

In addition add multiply operator for Intervals
Add docs for intervals and histogram

Fix #36509
2018-12-14 18:20:37 +02:00
Alan Woodward 09bf93dc2a
Add intervals query (#36135)
* Add IntervalQueryBuilder with support for match and combine intervals

* Add relative intervals

* feedback

* YAML test - broekn

* yaml test; begin to add block source

* Add block; make disjunction its own source

* WIP

* Extract IntervalBuilder and add tests for it

* Fix eq/hashcode in Disjunction

* New yaml test

* checkstyle

* license headers

* test fix

* YAML format

* YAML formatting again

* yaml tests; javadoc

* Add OR test -> requires fix from LUCENE-8586

* Add docs

* Re-do API

* Clint's API

* Delete bash script

* doc fixes

* imports

* docs

* test fix

* feedback

* comma

* docs fixes

* Tidy up doc references to old  rule
2018-12-14 15:14:00 +00:00
David Turner 278cc4c3de
[Zen2] Improve assertion when creating fake node ID (#36544)
Today we assert that the fake node ID is greater than the real node's ID. In
fact we want to assert that it's greater than _all_ proper UUIDs. This adds
assertions to that effect.
2018-12-14 14:16:26 +00:00
Costin Leau f502ca53d4
SQL: Introduce NOW/CURRENT_TIMESTAMP function (#36562)
Add CURRENT_TIMESTAMP as keyword as well function alongside NOW() 
 These return the current date/time for the  given query, computed when
 the statement reaches the server. For completeness, CURRENT_TIMESTAMP
 also accepts precision as an optional parameter.

Fix #36534
2018-12-14 15:42:36 +02:00
Jeff Hajewski f1f3b28f5c Delete deprecated getValues from ScriptDocValues (#36183)
* Adds deprecation logging to ScriptDocValues#getValues.

First commit addressing issue #22919.

`ScriptDocValues#getValues` was added for backwards compatibility but no
longer needed. Scripts using the syntax `doc['foo'].values` when
`doc['foo']` is a list should be using `doc['foo']` instead.

* Fixes two build errors in #34279

* Removes unused import in ScriptDocValuesDatesTest
* Removes used of `.values` in example in diversified-sampler-aggregation.asciidoc

* Removes use of .values from painless test.

Part of #34279

* Updates tests to use `doc[foo]` syntax rather than `doc[foo].values`.

* Removes use of `getValues()` and replaces use of `doc[foo].values` with `doc[foo]`.

* Indentation fix.

* Remove unnecessary list construction at previous `getValues()` callsite in ScriptDocValues.GeoPoints.

* Update migration doc and add link to `getValue` in ScriptDocValues javadoc.

* Fix compile

* Fix javadoc issue

* Removes ScriptDocValues#getValues usage from painless whitelist.
2018-12-14 07:56:47 -05:00
Marios Trivyzas db8f07c665
SQL: Fix translation to painless for conditionals (#36636)
Add missing `formatTemplate()` for conditional functions which
resulted in incomplete painless script. Moreover the specific
return type of Object in the painless signatures resulted in
casting exceptions when conditional functions are used in the
ORDER BY.

Fixes: #36631
2018-12-14 14:51:12 +02:00
Armin Braun 5df93218d5
SNAPSHOTS: Upgrade GCS Dependencies to 1.55.0 (#36634)
* Closes #35459
* Closes #35229
2018-12-14 13:24:29 +01:00
David Turner 245cdd8c34
Register ResyncTask.Status as a NamedWriteable (#36610)
Today, ResyncTask.Status is not registered, but appears as a task status
sometimes, leading to `Failed to deserialize response from handler` exceptions:

    java.lang.IllegalArgumentException: Unknown NamedWriteable [org.elasticsearch.tasks.Task$Status][resync]

This commit adds the missing registration.
2018-12-14 12:16:09 +00:00
David Turner 44ba9ab04d
Fix racy use of ConcurrentHashMap (#36603)
ConcurrentHashMap does not always behave correctly if removing elements and
concurrently checking for its emptyiness. Work around this by protecting all
usages with a mutex (there was only one usage unprotected by the mutex anyway)
and then we don't even need a ConcurrentHashMap at all.
2018-12-14 12:15:42 +00:00
Luca Cavanna 7dc3d3b78b
Add sort and collapse info to SearchHits transport serialization (#36555)
In order for CCS alternate execution mode (see #32125) to be able to do the final reduction step on the CCS coordinating node, we need to serialize additional info in the transport layer as part of the `SearchHits`, specifically:

- lucene `SortField[]` which contains info about the fields that sorting was performed on and their type, which depends on mappings (that the CCS node does not know about)
- collapse field (`String`) that field collapsing was executed on, if requested
- collapse values (`Object[]`) that field collapsing was based on, if requested

This info is needed to be able to reconstruct the `TopFieldDocs` or `CollapseFieldTopDocs` in the CCS coordinating node to feed the `mergeTopDocs` method and reduce multiple search responses received (one per cluster) into one.

This commit adds such information to the `SearchHits` class. It's nullable info that is not serialized through the REST layer. `SearchPhaseController` sets such info at the end of the hits reduction phase.
2018-12-14 12:22:54 +01:00
Armin Braun c5b3ac5578
SNAPSHOTS: Allow Parallel Restore Operations (#36397)
* Enable parallel restore operations
* Add uuid to restore in progress entries to uniquely identify them
* Adjust restore in progress entries to be a map in cluster state
* Added tests for:
   * Parallel restore from two different snapshots
   * Parallel restore from a single snapshot to different indices to test uuid identifiers are correctly used by `RestoreService` and routing allocator
   * Parallel restore with waiting for completion to test transport actions correctly use uuid identifiers
2018-12-14 11:39:23 +01:00
Nhat Nguyen 1ae53e6b20
TEST: Disable merges in testRebuildLocalCheckpointTracker (#36625)
In this test, we keep track of a list of index commits then verify that
we reload exactly every operation from the safe commit. If a background
merge is triggered, then we might have a new index commit which is not
recorded in the tracking list. This change disables merges in the test.

Closes #36470
2018-12-14 05:25:36 -05:00
Christoph Büscher 573b6325e7
[Tests] Fix edge case in SimpleQueryStringBuilderTests (#36611)
A previous fix of a similar problem in #35201 wasn't general enough, we also
need to catch cases where the randomly generated query string starts with some
version of "now" and hits a date field.

Closes #36595
2018-12-14 11:10:45 +01:00
David Pilato 5fe4c9076c Default ec2 endpoint is ec2.us-east-1.amazonaws.com (#30323)
Today our docs claim that the `discovery-ec2` plugin auto-detects the EC2
endpoint, but this is not the case. This fixes these docs.

Closes #27464.
2018-12-14 09:30:39 +00:00
Daniel Mitterdorfer b7ba2fa74b
Fix line length for VersionTests
Relates #34884
Relates #36585
2018-12-14 10:07:27 +01:00
Daniel Mitterdorfer 42f094952b
Fix line length for IndexLifecycleActionIT
Relates #34884
Relates #36586
2018-12-14 10:00:37 +01:00
Tal Levy 8a857983f7 [TEST] fix SecurityDocumentationIT#testGetUsers (#36622)
this test was failing because of two reason
- it was creating invalid users with passwords shorter than 6 characters
- it was expecting 7 total users to be returned, but it should be 9
2018-12-14 09:24:56 +01:00
David Roberts 690b10a4a1
[ML] Interrupt Grok in file structure finder timeout (#36588)
The file structure finder has timeout functionality,
but prior to this change it would not interrupt a
single long-running Grok match attempt.

This commit hooks into the ThreadWatchdog facility
provided by the Grok library to interrupt individual
Grok matches that may be running at the time the
file structure finder timeout expires.
2018-12-14 07:18:09 +00:00
Nhat Nguyen a4b32f1143
Remove concurrency in testFailLeaderReplicaShard (#36607)
testFailLeaderReplicaShard periodically fails because we concurrently
index to the leader group and close one of its replicas. If a
replication request hits a closing shard, we will fail that shard;
however, failing a shard is supported by the test framework - this makes
the test fail.
2018-12-13 19:02:13 -05:00
Nicholas Knize 0804c27fee fix error with SecurityDocumentationIT#testGetUsers 2018-12-13 17:35:38 -06:00
Marios Trivyzas 730b154c93
SQL: Fix MOD() for long and integer arguments (#36599)
Previously, Math.floorMod was used for integers and longs
which has different logic for negative numbers. Also, the
priority of data types check was wrong as if one of the args
is double the evaluation should be with doubles, then for floats,
then longs and finally integers.

Fixes: #36364
2018-12-14 00:59:42 +02:00
Andrei Stefan 1270d85ae1
SQL: be lenient for tests involving comparison to H2 but strict for csv spec tests (#36498)
* Add a lenient parameter for floating point numbers and mark csv-spec
tests as not lenient vs. sql-spec tests to be lenient.
2018-12-13 23:29:32 +02:00
Jason Tedor 692cff830a
Add guidance on using CCR with Logstash (#36609)
* Add guidance on using CCR with Logstash

This commit adds a note to the documentation regarding how to configure
Logstash indices in the context of being available as leader indices for
cross-cluster replication.

* Oh okay

* idk

* notconsole
2018-12-13 16:14:59 -05:00
Chris Earle 42d76a7e86
[Monitoring] LocalExporter should catch synchronous exceptions (#36606)
In the unlikely scenario that `LocalExporter::resolveBulk` throws
an exception, then we should mark the `listener` as having failed.
2018-12-13 16:13:26 -05:00
Gil Raphaelli 64da98070c format numbered list (#36580) 2018-12-13 12:44:34 -08:00
Ryan Ernst 254d1e8f22
Core: Add backcompat for joda time formats (#36531)
This commit adds deprecation warnings when using format specifiers with
joda data formats that will change with java time. It also adds the "8"
prefix which may be used to force the new java time format parsing.
2018-12-13 12:26:51 -08:00
Christoph Büscher b33ff16d62
Remove deprecated `useDisMax` from MultiMatchQuery (#36488)
The getters and setters for useDisMax() have been deprecated since at least 6.0,
also there hasn't been any reference to the query parameter in the
documentation. Removing it from the builder and tests and replacing it with
`tieBreaker(1.0f)` where necessary.
2018-12-13 20:13:16 +01:00
Nick Knize 4b17055035
HLRC: Add get users action (#36332)
This commit adds get user action to the high level rest client.
2018-12-13 12:24:48 -06:00
Tal Levy b820d7c617
fix MultiValuesSourceFieldConfig toXContent (#36525)
This commit turns MultiValuesSourceFieldConfig into a proper
ToXContentObject for easy testing and verification of its
to/from XContent methods.

Closes #36474.
2018-12-13 08:17:36 -08:00
Tal Levy e3cf642299
Add ILM-specific security privileges (#36493)
* add read_ilm cluster privilege

Although managing ILM policies is best done using the
"manage" cluster privilege, it is useful to have read-only
views.

* adds `read_ilm` cluster privilege for viewing policies and status
* adds Explain API to the `view_index_metadata` index privilege

* add manage_ilm privileges
2018-12-13 08:11:33 -08:00
Tim Brooks f998e04c34
Remove usages of `MockTcpTransport` from zen tests (#36579)
We are attempting to replace the usage of the `MockTcpTransport` with
the `MockNioTransport`. This commit replaces usages of
`MockTcpTransport` in two zen test cases.
2018-12-13 09:10:18 -07:00
Jason Tedor 2afa7faefd
Override the JVM DNS cache policy (#36570)
When a security manager is present, the JVM will cache positive hostname
lookups indefinitely. This can be problematic, especially in the modern
world with cloud services where DNS addresses can change, or
environments using Docker containers where IP addresses could be
considered ephemeral. This behavior impacts cluster discovery,
cross-cluster replication and cross-cluster search, reindex from remote,
snapshot repositories, webhooks in Watcher, external authentication
mechanisms, and the Elastic Stack Monitoring Service. The experience of
watching a DNS lookup change yet not be reflected within Elasticsearch
is a poor experience for users. The reason the JVM has this is guard
against DNS cache posioning attacks. Yet, there is already a defense in
the modern world against such attacks: TLS. With proper certificate
validation, even if a resolver falls prey to a DNS cache poisoning
attack, using TLS would neuter the attack. Therefore we have a policy
with dubious security value that significantly impacts usability. As
such we make the usability/security tradeoff towards usability, since
the security risks are very low. This commit introduces new system
properties that Elasticsearch observes to override the JVM DNS cache
policy.
2018-12-13 10:23:45 -05:00
Igor Motov 7446f75346
Geo: Adds a name of the field to geopoint parsing errors (#36529)
Adds the field name and type to geo_point parsing errors.

Closes #15965
2018-12-13 17:32:45 +04:00
Daniel Mitterdorfer 4d739d71d7
Document dynamic email settings in Watcher
With this commit we document which of the email notification settings in
Watcher can be set dynamically via the cluster settings API.

Relates #36543
2018-12-13 14:09:50 +01:00
Mayya Sharipova bda03163e7 Make vector fields experimental feature
Relates to #33022
2018-12-13 07:17:52 -05:00
Andrei Stefan 347468e916
SQL: do not ignore all fields whose names start with underscore (#36214)
* Do not ignore fields whose names start with underscore, unless they are
meta fields.
* Filter out _size field.
2018-12-13 14:05:16 +02:00
Armin Braun 088d3f39c3
MINOR: Cleanup Dead Code in o.e.c.metadata Package (#36587) 2018-12-13 12:54:22 +01:00
David Roberts 13cb0fb98b
Periodically try to reassign unassigned persistent tasks (#36069)
Previously persistent task assignment was checked in the
following situations:

- Persistent tasks are changed
- A node joins or leaves the cluster
- The routing table is changed
- Custom metadata in the cluster state is changed
- A new master node is elected

However, there could be situations when a persistent
task that could not be assigned to a node could become
assignable due to some other change, such as memory
usage on the nodes.

This change adds a timed recheck of persistent task
assignment to account for such situations.  The timer
is suspended while checks triggered by cluster state
changes are in-flight to avoid adding burden to an
already busy cluster.

Closes #35792
2018-12-13 09:15:27 +00:00
Armin Braun 34d7cc13c1
SETTINGS: Correctly Identify Noop Updates (#36560)
* We should compare the target value with the to be applied value before interpreting the update as a change
* This speeds up the test failing in #36496 considerably by preventing state updates on noop setting updates
2018-12-13 10:02:54 +01:00
Tim Vernum c650be72cf
[TEST] Prevent duplicate key in XContent test (#36581)
It was possible to generate a response that would output duplicate
keys

Closes: #36473
2018-12-13 19:39:59 +11:00
Boaz Leskes f6b5d7e013
Add sequence numbers based optimistic concurrency control support to Engine (#36467)
This commit add support to engine operations for resolving and verifying the sequence number and
primary term of the last modification to a document before performing an operation. This is
infrastructure to move our (optimistic concurrency control)[http://en.wikipedia.org/wiki/Optimistic_concurrency_control] API to use sequence numbers instead of internal versioning.

Relates #36148 
Relates #10708
2018-12-13 08:08:40 +01:00
Tal Levy cd1bec3a06
[refactor] add Environment in BootstrapContext (#36573)
There are certain BootstrapCheck checks that may need access environment-specific
values. Watcher's EncryptSensitiveDataBootstrapCheck passes in the node's environment
via a constructor to bypass the shortcoming in BootstrapContext. This commit
pulls in the node's environment into BootstrapContext.

Another case is found in #36519, where it is useful to check the state of the
data-path. Since PathUtils.get and Paths.get are forbidden APIs, we rely on
the environment to retrieve references to things like node data paths.

This means that the BootstrapContext will have the same Settings used in the
Environment, which currently differs from the Node's settings.
2018-12-12 21:07:21 -08:00
Mayya Sharipova d40037c91e
Deprecate uses of _type as a field name in queries (#36503) 2018-12-12 21:21:53 -05:00
Mayya Sharipova b5d532f9e3
Vector field (#33022)
1. Dense vector

PUT dindex
{
  "mappings": {
    "_doc": {
      "properties": {
        "my_vector": {
          "type": "dense_vector"
        },
        "my_text" : {
          "type" : "keyword"
        }
      }
    }
  }
}

PUT dinex/_doc/1
{
  "my_text" : "text1",
  "my_vector" : [ 0.5, 10, 6 ]
}

2. Sparse vector

PUT sindex
{
  "mappings": {
    "_doc": {
      "properties": {
        "my_vector": {
          "type": "sparse_vector"
        },
        "my_text" : {
          "type" : "keyword"
        }
      }
    }
  }
}

PUT sindex/_doc/1
{
  "my_text" : "text1",
  "my_vector" : {"1": 0.5, "99": -0.5,  "5": 1}
}
2018-12-12 21:20:53 -05:00
Tal Levy 9c1cdea839
[cleanup] remove deprecated references to dataWithClusterFiles (#36574)
data files under the cluster name subdirectory has been deprecated and was
meant to be removed in 6.0. This commit removes some leftover referrences to
these paths.
2018-12-12 16:28:11 -08:00
Gordon Brown 6a824322fc
Improve error message for deleting in-use policy (#36457)
The error message used when attempting to delete a lifecycle policy that
is in use previously only included one index which was using the policy.
It now includes all indices using that policy.
2018-12-12 14:57:48 -07:00
Julie Tibshirani 71a39d10be
Make sure that BWC tests run successfully, even with types deprecation messages. (#36511) 2018-12-12 12:57:32 -08:00
Alan Woodward 9ac7359643
Update lucene to snapshot-7e4555a2fd (#36563)
Includes the following:

* Reversion of doc-values changes in LUCENE-8374; we are interested in seeing if this 
  has an effect on benchmarks for node-stats and index-stats
* More improvements to docvalues updates
2018-12-12 20:18:32 +00:00
Jason Tedor 4a8cd45cca
Avoid blocking non-reproducible randomness in test (#36561)
The security documentation test uses
SecureRandom#getStrongInstance. This defaults to
securerandom.strongAlgorithms=NativePRNGBlocking:SUN,DRBG:SUN which
means a blocking implementation that reads from /dev/random. This means
that this test can stall if the entropy on the machine is
exhausted. Anyway, it also means that the randomness is
non-reproducible, a thing that we try to avoid in tests. This commit
switches to a boring randomness source to avoid the blocking, and to
keep the test reproducible.
2018-12-12 15:11:28 -05:00
Julie Tibshirani 33152f648f
Fix some inconsistencies in the types deprecation code. (#36517)
* Make sure to test conversion for both typed and typeless HLRC requests.
* Update a few more statements to deprecatedAndMaybeLog.
* Make sure Rest*SearchTemplateActionTests extend RestActionTestCase.
2018-12-12 10:38:02 -08:00