Commit Graph

9951 Commits

Author SHA1 Message Date
Zachary Tong ee857bc073 Aliases: Throw exception if index is null when creating alias
Fixes a bug where alias creation would allow `null` for index name, which thereby
applied the alias to _all_ indices.  This patch makes the validator throw an
exception if the index is null.

```bash
POST /_aliases
{
   "actions": [
      {
         "add": {
            "alias": "empty-alias",
            "index": null
         }
      }
   ]
}
```
```json
{
   "error": "ActionRequestValidationException[Validation Failed: 1: Alias action [add]: [index] may not be null;]",
   "status": 400
}
```

The reason this bug wasn't caught by the existing tests is because
the old test for nullness only validated against a cluster which had
zero indices.  The null index is translated into "_all", and since
there are no indices, this fails because the index doesn't exist.
 So the test passes.

However, as soon as you add an index, "_all" resolves and you get the
situation described in the original bug report:  null index is
accepted by the alias, resolves to "_all" and gets applied to everything.

Fixes #7976
2014-10-10 16:47:40 -04:00
Zachary Tong 4e2dd770aa Mapper: Throw exception if null_value is set to null
The mapping parser should throw an exception if "null_value" is set to `null`.

Fixes #7273

```bash
PUT /foo
{
  "mappings": {
    "bar": {
      "properties": {
        "exception": {
          "null_value": null,
          "type": "integer"
        }
      }
    }
  }
}
```
```
{
   "error": "MapperParsingException[mapping [bar]]; nested: MapperParsingException[Property [null_value] cannot be null.]; ",
   "status": 400
}
```
2014-10-10 16:29:23 -04:00
javanna 142d7bdd81 Internal: fixed bw comp in ShardSearchTransportRequest
Original indices were introduced in 1.4.0.Beta1 as optional, preceded by a boolean flag that told whether they were empty or not. We have to keep serializing as optional only when reading and writing from/to 1.4.0.Beta1, although the original indices are not optional whenever we go and serialize the request they belong to (which is why the boolean got removed in 1.4.0).
2014-10-10 21:47:45 +02:00
javanna 694cc08625 [TEST] bump benchmark apis version to 2.0.0 2014-10-10 20:53:19 +02:00
Ryan Ernst 6ac094c038 Add forgotten include for upgrade docs.
See #7922
2014-10-10 10:55:45 -07:00
Ryan Ernst e2c50c033a Add link to new upgrade docs from indices page.
See #7922.
2014-10-10 10:52:11 -07:00
Clinton Gormley 20a901964c Spec: Added human flag to indices.get_upgrade 2014-10-10 17:26:36 +02:00
Simon Willnauer 1792822bae [CORE] Log if CircuitBreaker is tripping
Today we only throw an exception which might not be logged at all. This
commit adds debug logging if we are tripping a CB.

Closes #8050
2014-10-10 13:02:46 +02:00
Adrien Grand 491a48e55b Docs: Remove the note that fielddata doesn't support filtering.
This particular note was about fielddata filtering but could cause confusion
that fields that have doc values enabled cannot be used for filtering (as in
a `filtered_query`).
2014-10-10 10:50:47 +02:00
Colin Goodheart-Smithe e9f05eed80 Aggregations: Fixes scripted metrics aggregation when used as a sub aggregation
The scripted metric aggregation is now a PER_BUCKET aggregation so that parent buckets are evaluated independently. Also the params and reduceParams are copied for each instance of the aggregator (each parent bucket) so modifications to the values are kept only within the scope of its parent bucket

Closes #8036
2014-10-10 08:54:26 +01:00
Michael McCandless 101ea31fdf Tests: move thread stacks on failure to a RunListener, so it actually works 2014-10-09 18:23:26 -04:00
Karel Minarik b1d4cec7ab [SPEC] Separated the "Upgrade Index" API into two methods
* `get_upgrade` => `GET _upgrade`  -- Return the status
* `upgrade`     => `POST _upgrade` -- Perform the operation

Original specification part of c021f22523.

Related: #7884, #7922
2014-10-09 16:19:58 +02:00
Michael McCandless 3729b8dbd6 Tests: dump all thread stacks on failure 2014-10-09 10:14:19 -04:00
Adrien Grand ede60df804 Fix serialization of short[] arays.
short[] were mistakenly encoded as a float[]. This is not an issue for the
text-based xcontents that we have (yaml, json) since floats can represent any
short value and are serialized as strings. However, this will make the binary
xcontents serialize shorts as int instead of floats.

Close #7845
2014-10-09 14:13:09 +02:00
Alex Ksikes 4ee91cb331 MLT Query: don't fetch unnecessary stats 2014-10-09 12:49:09 +02:00
Boaz Leskes 3d3c2cd760 add verbose logging during index close 2014-10-09 11:37:52 +02:00
Michael McCandless 668def0ddd Tests: add verbosity to this test case 2014-10-09 05:35:11 -04:00
Martijn van Groningen 5763b24686 Core: Make fetch phase nested doc aware
By letting the fetch phase understand the nested docs structure we can serve nested docs as hits.
The `top_hits` aggregation can because of this commit be placed in a `nested` or `reverse_nested` aggregation.

Closes #7164
2014-10-08 22:21:30 +02:00
javanna 3274e7ea6f Internal: split shard search request into a local and a transport variant
In some cases a shard search request gets created on a node to be only used there and never sent over the transport. This commit clarifies that and creates a new base class called `ShardSearchLocalRequest` that can and will be only used locally. `ShardSearchTransportRequest` on the other hand delegates to the local version but extends `TransportRequest` and is `Streamable`, which means that it is supposed to be sent over the transport.

This way we can make the `OriginalIndices` only required (and mandatory now) in the transport variant.

Took the chance to remove an unused InternalScrollSearchRequest constructor and an empty else branch in `TransportSearchScrollQueryAndFetchAction`.

Closes #7855
2014-10-08 18:57:04 +02:00
Britta Weber 96729b309d [TEST] fix test after pr #8020 2014-10-08 17:45:16 +02:00
Martijn van Groningen 6b26c2021a Parent/child: has_parent filter must take parent filter into account when executing the inner query/filter.
Closes #8020
Closes #7943
2014-10-08 16:50:26 +02:00
Colin Goodheart-Smithe 9ce7ca21e4 Docs: Added breaking changes docs for Indices APIs
Adds the breaking changes defaults for the change of default indices options for the GET Aliases API
2014-10-08 15:08:25 +01:00
Boaz Leskes fb39caa8d4 Tests: two corruptions can fix a file
In some of our tests we corrupt multiple places in a file randomly. If we corrupt the same place twice, we shouldn't fix the file by mistake.
2014-10-08 16:00:35 +02:00
Igor Motov 45d3842214 Docs: clarify wait_for_completion flag in snapshot documentation
Closes #7952
2014-10-08 08:43:06 -04:00
David Pilato 80ca8e5ab6 Admin: add total index memory in `_cat/indices`
This patch adds to `_cat/indices` information about memory usage per index by adding memory used by FieldData, IdCache, Percolate, Segments (memory, index writer, version map).

```
% curl 'localhost:9200/_cat/indices?v&h=i,tm'
i     tm
wiki  8.1gb
test  30.5kb
user  1.9mb
```

Closes #7008
2014-10-08 13:38:00 +02:00
Martijn van Groningen 41d3ba7f29 Tests: Enable check index in tests again.
* Run flush in beforeIndexShardClosed to prevent an empty shard.
* Only run check index if the shard state before closing was: started, relocated or post_recovery
2014-10-08 10:28:02 +02:00
Colin Goodheart-Smithe c047fbda9b Scripting: Created a parameter parse to standardised script options 2014-10-08 08:49:16 +01:00
Simon Willnauer e799ac9bd6 [TEST] Fix content comparison to not take platform dependent control chars into account. 2014-10-08 06:47:02 +02:00
Igor Motov 2359e33b1e Docs: fix formatting in snapshots documentation 2014-10-07 12:33:21 -04:00
Ryan Ernst 032184bd5e Fix missed places referencing optimize force flag from removal in commit 1ae8195. 2014-10-07 09:06:25 -07:00
Ryan Ernst c06c10bbb0 Remove deprecations from master (follow up to #7922) 2014-10-07 08:35:11 -07:00
Ryan Ernst c021f22523 Add Upgrade API
This commit does the following:
* Add the new API at the rest layer, being backed by the optimize API
  with upgrade flag, and segments api to find upgrade status.
* Add `upgrade` flag to optimize API, and deprecate `force` flag (will
  remove in master)
* Add test for both synchronous and async upgrade

closes #7884
closes #7922
2014-10-07 08:09:50 -07:00
Igor Motov 555bfcb02b [SNAPSHOT] Add repository validation
Fixes #7096
2014-10-07 10:50:16 -04:00
David Pilato 09ff3724ee plugins: disable support for config dir
When removing and installing again the plugin all configuration files will be removed in `config/pluginname` dir.
This is bad as users may have set and added specific configuration files.

During an install, if we detect already existing files in `config/pluginname` directory, we simply copy the new file to the same dir but we append a `.new` at the end.

Related to  #5064.

(cherry picked from commit 5da028f)
(cherry picked from commit 4cb1f95)
2014-10-07 16:16:37 +02:00
javanna 6cc7431bd3 [TEST] fix CurrentTestFailedMarker to reset its state after each test
The currently used method `testRunStarted` is only called before any tests have been run, we need to reset that state before each test, that's why we need to use `testStarted`.
2014-10-07 12:17:01 +02:00
Britta Weber 0408f90c08 [TEST] Fix config directory for external nodes in bwc tests
The logging configuration was expected in the path.home folder which is set to
target/JX
when running the bwc tests from the console.
Therefore the logger could not be initialized with error message:

[INFO] Failed to configure logging...
org.elasticsearch.ElasticsearchException: Failed to load logging configuration
        at org.elasticsearch.common.logging.log4j.LogConfigurator.resolveConfig(LogConfigurator.java:117)
        at org.elasticsearch.common.logging.log4j.LogConfigurator.configure(LogConfigurator.java:81)
        at org.elasticsearch.bootstrap.Bootstrap.setupLogging(Bootstrap.java:96)
        at org.elasticsearch.bootstrap.Bootstrap.main(Bootstrap.java:180)
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:32)
Caused by: java.nio.file.NoSuchFileException: /home/britta/es/target/J0/config
        at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
        at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
        at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
        at sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
        at sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:144)
        at sun.nio.fs.LinuxFileSystemProvider.readAttributes(LinuxFileSystemProvider.java:97)
        at java.nio.file.Files.readAttributes(Files.java:1686)
        at java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:109)
        at java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:69)
        at java.nio.file.Files.walkFileTree(Files.java:2602)
        at org.elasticsearch.common.logging.log4j.LogConfigurator.resolveConfig(LogConfigurator.java:107)
        ... 4 more
log4j:WARN No appenders could be found for logger (node).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

Setting the config directory fixes this.

Logs from external nodes are still not printed properly. They are inserted to the log
whenever the stdout is printed ([WARNING] JVM J0: stdout was not empty...)

closes #7964
2014-10-07 11:23:20 +02:00
Igor Motov c0129ebcc2 Snapshot/Restore: make it possible to delete snapshots with missing metadata file
Fixes #7980
2014-10-06 18:43:07 -04:00
Martijn van Groningen e1a8b027d7 Core: Perform write consistency just before writing on the primary shard
Before this change the write consistency change was performed on the node that receives the write request and the node that holds the primary shard. This change removes the check on the node that receives the request, since it is redundant.

Also this change moves the write consistency check on the node that holds the primary shard to a later moment after forking of the thread to perform the actual write on the primary shard.

Closes #7873
2014-10-06 19:00:07 +02:00
Boaz Leskes 99187e5259 Discovery: remove MasterFaultDetection.Listener.notListedOnMaster
It is never used in practice. We treat it as a master failure (using NodeDoesNotExistOnMasterException).

Closes #7995
2014-10-06 17:09:30 +02:00
David Pilato 6ae6a078de Search: add `format` support for date range filter and queries
When the date format is defined in mapping, you can not use another format when querying using range date query or filter.

For example, this won't work:

```
DELETE /test

PUT /test/t/1
{
  "date": "2014-01-01"
}

GET /test/_search
{
  "query": {
    "filtered": {
      "filter": {
        "range": {
          "date": {
            "from": "01/01/2014"
          }
        }
      }
    }
  }
}
```

It causes:

```
Caused by: org.elasticsearch.ElasticsearchParseException: failed to parse date field [01/01/2014], tried both date format [dateOptionalTime], and timestamp number
```

It could be nice if we can support at query time another date format just like we support `analyzer` at search time on String fields.

Something like:

```
GET /test/_search
{
  "query": {
    "filtered": {
      "filter": {
        "range": {
          "date": {
            "from": "01/01/2014",
            "format": "dd/MM/yyyy"
          }
        }
      }
    }
  }
}
```

Same for queries:

```
GET /test/_search
{
  "query": {
    "range": {
      "date": {
        "from": "01/01/2014",
        "format": "dd/MM/yyyy"
      }
    }
  }
}
```

Closes #7189.
2014-10-06 15:59:18 +02:00
Colin Goodheart-Smithe 6cf371395a Aggregations: makes script params consistent with other APIs in scripted_metric
This change removes the script_type parameter form the Scripted Metric Aggregation and adds support for _file and _id suffixes to the init_script, map_script, combine_script and reduce_script parameters to make defining the source of the script consistent with the other APIs which use the ScriptService
2014-10-06 09:07:25 +01:00
Igor Motov 2cbe1b9d59 Snapshot/Restore: Make sure indices cannot be renamed into restored aliases
Fixes #7915
2014-10-05 13:30:36 -04:00
Igor Motov 384114f52f Fix NPE in ScriptService when script file with no extension is deleted
Fixes #7689
2014-10-03 14:21:07 -04:00
Alex Ksikes 349b7a3a8b Term Vectors/MLT Query: support for different analyzers than default at field
This adds a `per_field_analyzer` parameter to the Term Vectors API, which
allows to override the default analyzer at the field. If the field already
stores term vectors, then they will be re-generated. Since the MLT Query uses
the Term Vectors API under its hood, this commits also adds the same ability
to the MLT Query, thereby allowing users to fine grain how each field item
should be processed and analyzed.

Closes #7801
2014-10-03 16:40:17 +02:00
Ryan Ernst d35d125ad8 Tests: Improve BWC preconditions to error cleanly when wire formats differ.
closes #7966
2014-10-03 07:37:02 -07:00
markharwood f878f40ae5 Aggs fix - background count for docs should include deleted docs otherwise a term’s docFreq (which includes deleted docs) can exceed the number of docs reported in the index and cause an exception.
The randomisation that deletes documents is also removed from tests as this doc-accounting change would mean the specific scores being expected in tests would now be subject to random variability and so fail.

Closes #7951
2014-10-03 13:20:39 +01:00
David Pilato f0052a58d6 Admin: show open and closed indices in _cat/indices
When asking for `GET /_cat/indices?v`, you can now retrieve closed indices in addition to opened ones.

```
health status index              pri rep docs.count docs.deleted store.size pri.store.size
yellow open   .marvel-2014.05.21   1   1       8792            0     21.7mb         21.7mb
       close  test
yellow open   .marvel-2014.05.22   1   1       3871            0     10.7mb         10.7mb
red    open   .marvel-2014.05.27   1   1
```

Closes #7907.
Closes #7936.
2014-10-03 13:16:14 +02:00
Adrien Grand 97816c135f Internal: Don't let `took` be negative.
`took` is computed based on the system clock and can be negative if the clock
time was updated during the execution of the search request. This commit
protects against these cases by replacing `took` with 1 if the elapsed time is
negative.

Close #7968
2014-10-03 12:25:22 +02:00
Adrien Grand bb6e2799cf Tests: Add more assertions to ExistsMissingTests. 2014-10-03 12:14:34 +02:00
Alex Ksikes c4830cf862 Term Vectors: support for realtime
By default term vectors are now realtime, as opposed to previously near
realtime. If they are not found in the index, they will be generated on the
fly. The document is fetched from the transaction log and treated as an
artificial document. One can set `realtime` parameter to `false` in order to
disable this functionality. This consequently makes the MLT query realtime in
fetching documents, as it previsouly used to be before switching from using
the multi get API to the mtv API.

Closes #7846
2014-10-03 09:26:47 +02:00