Commit Graph

187 Commits

Author SHA1 Message Date
Ignacio Vera 368e2e0755
Add 'mvt' field type format to geo fields (#75367)
In this commit we extend the Fields API formats for geo data in order to produce vector tiles features directly 
on the data nodes. That helps the vector tile API to reduce the size of the data that needs to pull in order to 
create the answer.
2021-07-28 09:24:54 +02:00
Rory Hunter 944b3f3b56
Fix compiler warnings in :server - part 1 (#75708)
Part of #40366. Fix a number of javac issues when linting is enforced in `server/`.
2021-07-27 19:40:40 +01:00
Ignacio Vera 02c29433d1
Vector tiles: order hits by geometry size by default (#75621)
_mvt end point gives priority to geometries with larger area
2021-07-27 18:34:21 +02:00
Ignacio Vera dcd38779f9
Geometry formatters should be applied to the full array (#75177)
Changes the way we fetch values from source in geo fields so we can format all data in one go.
2021-07-14 16:23:30 +02:00
Ignacio Vera ebe8a9b58f
Alias field does not work with geo_shape query (#74895)
Fixes the resolution of the field name in the geo_shape query.
2021-07-08 07:19:38 +02:00
Luca Cavanna c6641bf00c
Rename ParseContext to DocumentParserContext (#74963)
ParseContext is used to parse documents. It was easily confused with ParserContext (now renamed to MappingParserContext) which is instead used to parse mappings.

To remove any confusion, this commit renames ParseContext to DocumentParserContext and adapts its subclasses accordingly.
2021-07-06 09:15:59 -04:00
Ignacio Vera 0f30c79e4b
Remove legacy geo code from AbstractGeometryQueryBuilder classes (#74741)
removes references to Legacy ShapeParser and ShapeBuilder in AbstractGeometryQueryBuilder classes 
in favour to Geometry and GeometryParser.
2021-07-05 07:31:55 +02:00
Przemyslaw Gomulka 4fa1c8db46
[Rest Api Compatibility] Allow for type in geo shape query (#74553)
Allowing to specify type in geo_shape query. previously removed by #47792
types removal compatible meta #54160
main meta issue #51816
2021-06-30 12:38:24 +02:00
Ignacio Vera cda050de3e
Fix computation of max cells for bounded geohash grid aggregation (#74542)
computation of max cells is actually underestimated so it can lead to an AOOB exception.
2021-06-29 07:31:01 +02:00
Ignacio Vera 7e246e8d82
Fix double counting GeoTileGrid aggregation (#74353)
Fix issue when bounding box crosses the dateline and covers all longitude values.
2021-06-22 08:03:52 +02:00
Ignacio Vera 603be001a9
Set parsesArrayValue to true for Shape field mappers (#73940)
bring shape and point implementation close together.
2021-06-09 11:31:33 +02:00
Ignacio Vera 1ed587d102
Move orientation enum out of ShapeBuilder (#73824) 2021-06-09 07:58:17 +02:00
Ignacio Vera 6466ce752d
Separate parsing geo format from fields API geo formats (#73806)
This change removes the current GeometryFormat interface and replace then with a GeometryParser that deals 
with Parsing formats and a GeometryFormatFactory that deals with fields API formats.
2021-06-09 06:32:12 +02:00
Ryan Ernst 63012c8a40
Move ParseField to o.e.c.xcontent (#73923)
ParseField is part of the x-content lib, yet it doesn't exist under the
same root package as the rest of the lib. This commit moves the class to
the appropriate package.

relates #73784
2021-06-08 13:32:14 -07:00
Ryan Ernst 68817d7ca2
Rename o.e.common in libs/core to o.e.core (#73909)
When libs/core was created, several classes were moved from server's
o.e.common package, but they were not moved to a new package. Split
packages need to go away long term, so that Elasticsearch can even think
about modularization. This commit moves all the classes under o.e.common
in core to o.e.core.

relates #73784
2021-06-08 09:53:28 -07:00
Ignacio Vera d42c0cf016
Make methods in GeoJson and WellKnownText static (#73805)
This change makes all methods on those utility classes static.
2021-06-08 08:37:29 +02:00
Ignacio Vera 7f5ff7167c
GeoShapeIndexer#prepareForIndex should be called for computing the doc value centroid (#73856) 2021-06-08 06:14:23 +02:00
Ignacio Vera 094f193ee2
Remove ParsedPoint interface from point field mappers (#73710) 2021-06-04 17:24:02 +02:00
Ignacio Vera 409b6cefe3
Add painless script support for geo_shape field (#72886)
Users can access the centroid, bounding box and dimensional type of the shape.
2021-05-26 18:55:45 +02:00
Ignacio Vera 157f5336db
speed up geotile aggregation over geo_shape field (#72984)
compute the range of tiles that needs to be added instead of using recursion.
2021-05-26 07:16:17 +02:00
Ignacio Vera 310342fc2e
Fix test testGeoShapeBounds (#72878)
computing hashes for points is consistent between geo_shape and geo_point
2021-05-12 06:48:04 +02:00
Ignacio Vera 15da180b0c
mute GeoShapeGeoHashGridAggregatorTests#testGeoShapeBounds (#72873) 2021-05-10 09:53:48 +02:00
Ignacio Vera 5407824cda
Handle properly precision 0 for BoundedGeoTileGrid (#72800)
For GeoTileAggregation, the relationship between the grid and the bounded box
can be disjoint.
2021-05-10 07:56:21 +02:00
Rene Groeschke e609e07cfe
Remove internal build logic from public build tool plugins (#72470)
Extract usage of internal API from TestClustersPlugin and PluginBuildPlugin and related plugins and build logic

This includes a refactoring of ElasticsearchDistribution to handle types
better in a way we can differentiate between supported Elasticsearch
Distribution types supported in TestCkustersPlugin and types only supported
in internal plugins.

It also introduces a set of internal versions of public plugins.

As part of this we also generate the plugin descriptors now.

As a follow up on this we can actually move these public used classes into 
an extra project (declared as included build)

We keep LoggedExec and VersionProperties effectively public And workaround for RestTestBase
2021-05-06 14:02:35 +02:00
Ignacio Vera 893d4efc41
Do not over-allocate when resizing in GeoHashTiler with bounds (#72539) 2021-05-03 10:18:35 +02:00
Ignacio Vera 4fff3788f3
Disallow creating geo_shape mappings with deprecated parameters (#70850)
With the introduction of BKD-based geo shape indexing in #32039, the prefix tree indexing method has 
been deprecated. From 8.0.0, it will not be allowed to create new mappings using deprecated parameters.
2021-04-30 11:08:58 +02:00
Alan Woodward 009f23e7a9
Explicitly say if stored fields aren't supported in MapperTestCase (#72474)
MapperTestCase has a check that if a field mapper supports stored fields,
those stored fields are available to index time scripts. Many of our mappers
do not support stored fields, and we try and catch this with an assumeFalse
so that those mappers do not run this test. However, this test is fragile - it
does not work for mappers created with an index version below 8.0, and it
misses mappers that always store their values, e.g. match_only_text.

This commit adds a new supportsStoredField method to MapperTestCase,
and overrides it for those mappers that do not support storing values. It
also adds a minimalStoredMapping method that defaults to the minimal
mapping plus a store parameter, which is overridden by match_only_text
because storing is not configurable and always available on this mapper.
2021-04-30 08:59:56 +01:00
Ignacio Vera 17717a0f6b
mute testGeoHashBoundsExcludeTouchingTiles (#72522) 2021-04-30 09:05:14 +02:00
Ignacio Vera 65aa3e7478
Avoid numerical error for sub-atomic values in GeoGridAggregation (#72394)
This change avoid creating sub-atomic values for GeoGridAggregation bounds.
2021-04-29 07:09:56 +02:00
Ignacio Vera 903f6fc1e8
Grid aggregations with bounds should exclude touching tiles (#72295) 2021-04-28 08:19:44 +02:00
Alan Woodward e002aa809b
Make FieldNamesFieldMapper responsible for adding its own doc fields (#71929)
The FieldNamesFieldMapper is a metadata mapper defining a field that
can be used for exists queries if a mapper does not use doc values or
norms. Currently, data is added to it via a special method on FieldMapper
that pulls the metadata mapper from a mapping lookup, checks to see
if it is enabled, and then adds the relevant value to a lucene document.

This is one of only two places that pulls a metadata mapper from the
MappingLookup, and it would be nice to remove this method. This commit
refactors field name handling by instead storing the names of fields to
index in the fieldnames field in a set on the ParseContext, and then
building the field itself in FieldNamesFieldMapper.postParse(). This means
that all of the responsibility for enabling indexing, etc, is handled within
the metadata mapper itself.
2021-04-27 16:03:46 +01:00
Ignacio Vera 423c47ac56
Refactor GeoGridTiler classes (#72201)
This PR introduces the classes  AbstractGeoHashGridTiler and AbstractGeoTileGridTiler in order to 
simplify the current class hierarchy.
2021-04-27 08:21:37 +02:00
Alan Woodward 72f9c4c122
Add null-field checks to shape field mappers (#71999)
#71696 introduced a regression to the various shape field mappers,
where they would no longer handle null values. This commit fixes
that regression and adds a testNullValues method to MapperTestCase
to ensure that all field mappers correctly handle nulls.

Fixes #71874
2021-04-21 15:54:22 +01:00
Alan Woodward 630a43f9bd
Add deprecation warnings to geo fields that define multifields (#71912)
With the exception of geo_point, no geometry field mappers actually support
the use of multifields. However, we happily accept multifield definitions on these
mappers and silently ignore them when it comes to indexing documents. With
this commit, we emit deprecation warnings when a multifield definition is included
on a geometry field mapper that does not in fact support one.
2021-04-21 13:14:37 +01:00
Alan Woodward ee3510b766
Add index-time scripts to geo_point field mapper (#71861)
This commit adds the ability to define an index-time geo_point field
with a script parameter, allowing you to calculate points from other
values within the indexed document.
2021-04-20 10:24:25 +01:00
Alan Woodward 289d202cb2
Rework geo mappers to index value by value (#71696)
The various geo field mappers are organised in a hierarchy that shares
parsing and indexing code. This ends up over-complicating things,
particularly when we have some mappers that accept multiple values
and others that only accept singletons. It also leads to confusing
behaviour around ignore_malformed behaviour: geo fields will ignore
all values if a single one is badly formed, while all other field mappers
will only ignore the problem value and index the rest. Finally, this
structure makes adding index-time scripts to geo_point needlessly
complex.

This commit refactors the indexing logic of the hierarchy to move the
individual value indexing logic into the concrete implementations,
and aligns the ignore_malformed behaviour with that of other mappers.

It contains two breaking changes:

* The geo field mappers no longer check for external field values on the
  parse context. This added considerable complication to the refactored
  parse methods, and is unused anywhere in our codebase, but may
  impact plugin-based field mappers which expect to use geo fields
  as multifields
* The geo_point field mapper now passes geohashes to its multifields
  one-by-one, instead of formatting them into a comma-delimited
  string and passing them all at once. Completion multifields using
  this as an input should still behave as normal because by default
  they would split this combined geohash string on the commas in any
  case, but keyword subfields may look different.

Fixes #69601
2021-04-19 12:38:01 +01:00
Lyudmila Fokina 3b0b7941ae
Warn users if security is implicitly disabled (#70114)
* Warn users if security is implicitly disabled

Elasticsearch has security features implicitly disabled by default for
Basic and Trial licenses, unless explicitly set in the configuration
file.
This may be good for onboarding, but it also lead to unintended insecure
 clusters.
 This change introduces clear warnings when security features are
 implicitly disabled.
 - a warning header in each REST response if security is implicitly
 disabled;
 - a log message during cluster boot.
2021-04-13 18:33:41 +02:00
Joe Gallo 2a0ec50d47
Apply REST API compatibility testing for the :x-pack plugins (#71302) 2021-04-06 11:35:33 -04:00
Alan Woodward 1653f2fe91
Add script parameter to long and double field mappers (#69531)
This commit adds a script parameter to long and double fields that makes
it possible to calculate a value for these fields at index time. It uses the same
script context as the equivalent runtime fields, and allows for multiple index-time
scripted fields to cross-refer while still checking for indirection loops.
2021-03-31 11:14:11 +01:00
Ignacio Vera a35563aaaf
Fix infinite loop when polygonizing a circle with centre on the pole (#70875)
This PR prevents the algorithm to run on circles that contain a pole.
2021-03-29 07:36:29 +02:00
Mark Vieira 6339691fe3
Consolidate REST API specifications and publish under Apache 2.0 license (#70036) 2021-03-26 16:20:14 -07:00
Nik Everett 91c700bd99
Super randomized tests for fetch fields API (#70278)
We've had a few bugs in the fields API where is doesn't behave like we'd
expect. Typically this happens because it isn't obvious what we expct. So
we'll try and use randomized testing to ferret out what we want. This adds
a test for most field types that asserts that `fields` works similarly
to `docvalues_fields`. We expect this to be true for most fields.

It does so by forcing all subclasses of `MapperTestCase` to define a
method that makes random values. It declares a few other hooks that
subclasses can override to further randomize the test.

We skip the test for a few field types that don't have doc values:
* `annotated_text`
* `completion`
* `search_as_you_type`
* `text`
We should come up with some way to test these without doc values, even
if it isn't as nice. But that is a problem for another time, I think.

We skip the test for a few more types just because I wanted to cut this
PR in half so we could get to reviewing it earlier. We'll get to those
in a follow up change.

I've filed a few bugs for things that are inconsistent with
`docvalues_fields`. Typically that means that we have to limit the
random values that we generate to those that *do* round trip properly.
2021-03-24 14:16:27 -04:00
Ignacio Vera 7763470e39
Fix overflow in GeoTileGridTiler (#70222)
This PR uses longs to compute the number of tiles touching a bounding box
2021-03-11 06:41:33 +01:00
Ignacio Vera b51a5aff48
Do not over-allocate when resizing in GeoGridTiler (#70159)
A missing parenthesis is missing when calculating the size of the array which might lead to an 
oversize array.
2021-03-10 07:37:24 +01:00
Alan Woodward 139ff8657a
Require `meta` field for MappedFieldType to be non-null (#70145)
The transport action for FieldCapabilities assumes the meta field for a MappedFieldType
is traversable. This commit adds a requirement to MappedFieldType itself to ensure that
it is implemented for all subtypes.
2021-03-09 15:40:03 +00:00
Nik Everett 10e2f90560
Speed up aggs with sub-aggregations (#69806)
This allows many of the optimizations added in #63643 and #68871 to run
on aggregations with sub-aggregations. This should:
* Speed up `terms` aggregations on fields with less than 1000 values that
  also have sub-aggregations. Locally I see 2 second searches run in 1.2
  seconds.
* Applies that same speedup to `range` and `date_histogram` aggregations but
  it feels less impressive because the point range queries are a little
  slower to get up and go.
* Massively speed up `filters` aggregations with sub-aggregations that
  don't have a `parent` aggregation or collect "other" buckets. Also
  save a ton of memory while collecting them.
2021-03-03 18:04:47 -05:00
Alan Woodward 5f478ac1a1
Always validate geo shapes when fetching (#69104)
The ValueFetcher for geo_shape will shortcut the validation of its
source value if it detects that the source format and the requested
format are the same. This worked fine when malformed values were
dealt with by checking the _ignored metadata, but since #68738
we need to always validate source values at fetch time.

This commit removes this special shortcut logic, and adds tests
to check that geo_shape value fetchers do not return malformed
source inputs.

Fixes #69071
2021-03-01 11:31:11 +00:00
Tal Levy cc776beefd
Fix geo_line agg behavior with missing values (#69395)
The geo_line aggregation incorrectly handled results with missing values. Tests to verify this
behavior were incorrectly checking results. This commit resolves these in three ways

- explicitly testing  missing sort field values
- explicitly testing handling missing point field values
- explicitly testing handling mixed scenarios where some documents have one and not the other, or missing both.

Fixes https://github.com/elastic/kibana/issues/90653.

Fixes #69346.
2021-02-23 12:29:49 -08:00
Benjamin Trent 1438434b6c
[Transform] add support for geo_line aggregation in pivot function (#69299)
This commit adds support for the Gold+ licensed `geo_line` aggregation.

This aggregation takes a collection of `geo_point` values and constructs a line
according to some sort value. Adding to transforms allows users to create these
potentially expensive lines out of band of visualizations and then do additional aggs/queries
against the pivoted data. 

Examples would be:

"Do these daily user paths ever intersect?"
"Does this path enter and leave this area?"
2021-02-23 14:53:36 -05:00
Rene Groeschke bdf229a148
Introduce Internal Test Artifact Plugin (#68766)
This reduces the ceremony declaring test artifacts for a project.
It also solves an issue with usage of deprecated testRuntime that
testArtifacts extendsFrom which seems not required at all and would have
broke with Gradle 7.0 anyhow

Test artifact resolution is now variant aware which allows us a more adequate 
compile and runtime classpath for the consuming projects.

We also Introduce a convention method in the elasticsearch build to declare 
test artifact dependencies in an easy way close to how its done by the gradle build in 
test fixture plugin.

Furthermore we cleaned up some inconsistent test dependencies declarations when 
relying on a project and on its test artifacts
2021-02-16 14:36:17 +01:00