Skip to content

Commit 4a52b39

Browse files
russcamMpdreamz
authored andcommitted
Fix 6.x query validity in integration tests (#3999)
* Send queries to cluster when running integration tests * Do not set _id and routing automatically (#3805) This commit updates LikeDocument so that _id and routing are not set when a document input is used. Routing is required in the MoreLikeThisFullDocumentQueryUsageTests because the Project type mapping requires routing, but this should not be the default. Fixes #3977 * Fix Query DSL usage tests (#3804) This commit removes the lenient assertion within QueryDslUsagesTestsBase that allowed parsing exceptions in Elasticsearch to pass. This was a temporary solution whilst upgrading the client to work with Elasticsearch 7.x. Add an IGeoShape property to Project called LocationShape, and always seeds it with a PointGeoShape. Rename Location to LocationPoint Update the GeoShapeFormatter to skip over the value of a field within JSON when it is not the type field. String allocations for property names are reduced by comparing fields to static byte fields. Fix the serialized ordering of lat lon values in the geo_shape query using an envelope, since server side validation only allows valid envelopes. Skip multi_point and circle geo_shape queries for now as both result in 400 error responses. Do not set id when MoreLikeThis query input is a document GeoPolygon query requires a minimum of 3 coordinates * Fix span query integration tests This commit fixes the span query integration tests. Fix namespaces. * Fix HasChild query integration tests This commit introduces a TypeRelation property of type RelationName and deprecates Type property. The property should be RelationName to correctly infer the relation. * Valid script in script query usage tests * Add routing value to More like this query * Use tag nested field in nested query usage tests * skip geo shape query tests on >=6.6.0 This commit skips geo shape queries for circles and multi_point above 6.6.0. These queries are not supported against BKD backed shapes * fix query_string query integration tests * Update docs * Assert AfterKey is not null only on >= 6.3.0 * Use static First Project property * Valid queries
1 parent 178d354 commit 4a52b39

File tree

84 files changed

+623
-553
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+623
-553
lines changed

docs/aggregations/bucket/composite/composite-aggregation-usage.asciidoc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,15 @@ response.ShouldBeValid();
155155
var composite = response.Aggregations.Composite("my_buckets");
156156
composite.Should().NotBeNull();
157157
composite.Buckets.Should().NotBeNullOrEmpty();
158-
composite.AfterKey.Should().NotBeNull();
158+
159159
if (TestConfiguration.Instance.InRange(">=6.3.0"))
160+
{
161+
composite.AfterKey.Should().NotBeNull();
160162
composite.AfterKey.Should()
161163
.HaveCount(3)
162164
.And.ContainKeys("branches", "started", "branch_count");
165+
}
166+
163167
foreach (var item in composite.Buckets)
164168
{
165169
var key = item.Key;

docs/aggregations/bucket/geo-distance/geo-distance-aggregation-usage.asciidoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ please modify the original csharp file found at the link and submit the PR with
2121
----
2222
a => a
2323
.GeoDistance("rings_around_amsterdam", g => g
24-
.Field(p => p.Location)
24+
.Field(p => p.LocationPoint)
2525
.Origin(52.376, 4.894)
2626
.Ranges(
2727
r => r.To(100),
@@ -37,7 +37,7 @@ a => a
3737
----
3838
new GeoDistanceAggregation("rings_around_amsterdam")
3939
{
40-
Field = Field((Project p) => p.Location),
40+
Field = Field((Project p) => p.LocationPoint),
4141
Origin = "52.376, 4.894",
4242
Ranges = new List<AggregationRange>
4343
{
@@ -54,7 +54,7 @@ new GeoDistanceAggregation("rings_around_amsterdam")
5454
{
5555
"rings_around_amsterdam": {
5656
"geo_distance": {
57-
"field": "location",
57+
"field": "locationPoint",
5858
"origin": {
5959
"lat": 52.376,
6060
"lon": 4.894

docs/aggregations/bucket/geo-hash-grid/geo-hash-grid-aggregation-usage.asciidoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ please modify the original csharp file found at the link and submit the PR with
2121
----
2222
a => a
2323
.GeoHash("my_geohash_grid", g => g
24-
.Field(p => p.Location)
24+
.Field(p => p.LocationPoint)
2525
.GeoHashPrecision(GeoHashPrecision.Precision3)
2626
.Size(1000)
2727
.ShardSize(100)
@@ -34,7 +34,7 @@ a => a
3434
----
3535
new GeoHashGridAggregation("my_geohash_grid")
3636
{
37-
Field = Field<Project>(p => p.Location),
37+
Field = Field<Project>(p => p.LocationPoint),
3838
Precision = GeoHashPrecision.Precision3,
3939
Size = 1000,
4040
ShardSize = 100
@@ -47,7 +47,7 @@ new GeoHashGridAggregation("my_geohash_grid")
4747
{
4848
"my_geohash_grid": {
4949
"geohash_grid": {
50-
"field": "location",
50+
"field": "locationPoint",
5151
"precision": 3,
5252
"size": 1000,
5353
"shard_size": 100

docs/aggregations/metric/geo-bounds/geo-bounds-aggregation-usage.asciidoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ please modify the original csharp file found at the link and submit the PR with
2121
----
2222
a => a
2323
.GeoBounds("viewport", gb => gb
24-
.Field(p => p.Location)
24+
.Field(p => p.LocationPoint)
2525
.WrapLongitude(true)
2626
)
2727
----
@@ -30,7 +30,7 @@ a => a
3030

3131
[source,csharp]
3232
----
33-
new GeoBoundsAggregation("viewport", Field<Project>(p => p.Location))
33+
new GeoBoundsAggregation("viewport", Field<Project>(p => p.LocationPoint))
3434
{
3535
WrapLongitude = true
3636
}
@@ -42,7 +42,7 @@ new GeoBoundsAggregation("viewport", Field<Project>(p => p.Location))
4242
{
4343
"viewport": {
4444
"geo_bounds": {
45-
"field": "location",
45+
"field": "locationPoint",
4646
"wrap_longitude": true
4747
}
4848
}

docs/aggregations/metric/geo-centroid/geo-centroid-aggregation-usage.asciidoc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ Be sure to read the Elasticsearch documentation on {ref_current}/search-aggregat
2626
----
2727
a => a
2828
.GeoCentroid("centroid", gb => gb
29-
.Field(p => p.Location)
29+
.Field(p => p.LocationPoint)
3030
)
3131
----
3232

3333
==== Object Initializer syntax example
3434

3535
[source,csharp]
3636
----
37-
new GeoCentroidAggregation("centroid", Infer.Field<Project>(p => p.Location))
37+
new GeoCentroidAggregation("centroid", Infer.Field<Project>(p => p.LocationPoint))
3838
----
3939

4040
[source,javascript]
@@ -43,7 +43,7 @@ new GeoCentroidAggregation("centroid", Infer.Field<Project>(p => p.Location))
4343
{
4444
"centroid": {
4545
"geo_centroid": {
46-
"field": "location"
46+
"field": "locationPoint"
4747
}
4848
}
4949
}
@@ -78,7 +78,7 @@ a => a
7878
.Field(p => p.Name)
7979
.Aggregations(sa => sa
8080
.GeoCentroid("centroid", gb => gb
81-
.Field(p => p.Location)
81+
.Field(p => p.LocationPoint)
8282
)
8383
)
8484
)
@@ -91,7 +91,7 @@ a => a
9191
new TermsAggregation("projects")
9292
{
9393
Field = Infer.Field<Project>(p => p.Name),
94-
Aggregations = new GeoCentroidAggregation("centroid", Infer.Field<Project>(p => p.Location))
94+
Aggregations = new GeoCentroidAggregation("centroid", Infer.Field<Project>(p => p.LocationPoint))
9595
}
9696
----
9797

@@ -106,7 +106,7 @@ new TermsAggregation("projects")
106106
"aggs": {
107107
"centroid": {
108108
"geo_centroid": {
109-
"field": "location"
109+
"field": "locationPoint"
110110
}
111111
}
112112
}
@@ -140,15 +140,15 @@ foreach (var bucket in projects.Buckets)
140140
----
141141
a => a
142142
.GeoCentroid("centroid", gb => gb
143-
.Field(p => p.Location)
143+
.Field(p => p.LocationPoint)
144144
)
145145
----
146146

147147
==== Object Initializer syntax example
148148

149149
[source,csharp]
150150
----
151-
new GeoCentroidAggregation("centroid", Infer.Field<Project>(p => p.Location))
151+
new GeoCentroidAggregation("centroid", Infer.Field<Project>(p => p.LocationPoint))
152152
----
153153

154154
[source,javascript]
@@ -157,7 +157,7 @@ new GeoCentroidAggregation("centroid", Infer.Field<Project>(p => p.Location))
157157
{
158158
"centroid": {
159159
"geo_centroid": {
160-
"field": "location"
160+
"field": "locationPoint"
161161
}
162162
}
163163
}

docs/query-dsl.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ See the Elasticsearch documentation on {ref_current}/span-queries.html[Span quer
355355

356356
:includes-from-dirs: query-dsl/span
357357

358-
include::query-dsl/span/container/span-containing-query-usage.asciidoc[]
358+
include::query-dsl/span/containing/span-containing-query-usage.asciidoc[]
359359

360360
include::query-dsl/span/field-masking/span-field-masking-usage.asciidoc[]
361361

docs/query-dsl/compound/function-score/function-score-query-usage.asciidoc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ q
3232
.Exponential(b => b.Field(p => p.NumberOfCommits).Decay(0.5).Origin(1.0).Scale(0.1).Weight(2.1))
3333
.GaussDate(b => b.Field(p => p.LastActivity).Origin(DateMath.Now).Decay(0.5).Scale("1d"))
3434
.LinearGeoLocation(b =>
35-
b.Field(p => p.Location).Origin(new GeoLocation(70, -70)).Scale(Distance.Miles(1)).MultiValueMode(MultiValueMode.Average))
36-
.FieldValueFactor(b => b.Field("x").Factor(1.1).Missing(0.1).Modifier(FieldValueFactorModifier.Ln))
35+
b.Field(p => p.LocationPoint).Origin(new GeoLocation(70, -70)).Scale(Distance.Miles(1)).MultiValueMode(MultiValueMode.Average))
36+
.FieldValueFactor(b => b.Field(p => p.NumberOfContributors).Factor(1.1).Missing(0.1).Modifier(FieldValueFactorModifier.Square))
3737
.RandomScore(r => r.Seed(1337).Field("_seq_no"))
3838
.RandomScore(r => r.Seed("randomstring").Field("_seq_no"))
3939
.Weight(1.0)
40-
.ScriptScore(ss => ss.Script(s => s.Id("x")))
40+
.ScriptScore(s => s.Script(ss => ss.Source("Math.log(2 + doc['numberOfCommits'].value)")))
4141
)
4242
)
4343
----
@@ -62,17 +62,17 @@ new FunctionScoreQuery()
6262
{ Origin = DateMath.Now, Field = Field<Project>(p => p.LastActivity), Decay = 0.5, Scale = TimeSpan.FromDays(1) },
6363
new LinearGeoDecayFunction
6464
{
65-
Origin = new GeoLocation(70, -70), Field = Field<Project>(p => p.Location), Scale = Distance.Miles(1),
65+
Origin = new GeoLocation(70, -70), Field = Field<Project>(p => p.LocationPoint), Scale = Distance.Miles(1),
6666
MultiValueMode = MultiValueMode.Average
6767
},
6868
new FieldValueFactorFunction
6969
{
70-
Field = "x", Factor = 1.1, Missing = 0.1, Modifier = FieldValueFactorModifier.Ln
70+
Field = Field<Project>(p => p.NumberOfContributors), Factor = 1.1, Missing = 0.1, Modifier = FieldValueFactorModifier.Square
7171
},
7272
new RandomScoreFunction { Seed = 1337, Field = "_seq_no" },
7373
new RandomScoreFunction { Seed = "randomstring", Field = "_seq_no" },
7474
new WeightFunction { Weight = 1.0 },
75-
new ScriptScoreFunction { Script = new ScriptQuery { Id = "x" } }
75+
new ScriptScoreFunction { Script = new ScriptQuery{ Source = "Math.log(2 + doc['numberOfCommits'].value)" } }
7676
}
7777
}
7878
----
@@ -107,7 +107,7 @@ new FunctionScoreQuery()
107107
},
108108
{
109109
"linear": {
110-
"location": {
110+
"locationPoint": {
111111
"origin": {
112112
"lat": 70.0,
113113
"lon": -70.0
@@ -119,10 +119,10 @@ new FunctionScoreQuery()
119119
},
120120
{
121121
"field_value_factor": {
122-
"field": "x",
122+
"field": "numberOfContributors",
123123
"factor": 1.1,
124124
"missing": 0.1,
125-
"modifier": "ln"
125+
"modifier": "square"
126126
}
127127
},
128128
{
@@ -143,7 +143,7 @@ new FunctionScoreQuery()
143143
{
144144
"script_score": {
145145
"script": {
146-
"id": "x"
146+
"source": "Math.log(2 + doc['numberOfCommits'].value)"
147147
}
148148
}
149149
}

docs/query-dsl/full-text/query-string/query-string-usage.asciidoc

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@ q
2525
.Boost(1.1)
2626
.Fields(f => f.Field(p => p.Description).Field("myOtherField"))
2727
.Query("hello world")
28-
.DefaultField(p => p.Description)
2928
.DefaultOperator(Operator.Or)
3029
.Analyzer("standard")
31-
.QuoteAnalyzer("quote-an")
30+
.QuoteAnalyzer("keyword")
3231
.AllowLeadingWildcard()
3332
.MaximumDeterminizedStates(2)
3433
.Escape()
@@ -55,10 +54,9 @@ new QueryStringQuery
5554
Boost = 1.1,
5655
Name = "named_query",
5756
Query = "hello world",
58-
DefaultField = Field<Project>(p => p.Description),
5957
DefaultOperator = Operator.Or,
6058
Analyzer = "standard",
61-
QuoteAnalyzer = "quote-an",
59+
QuoteAnalyzer = "keyword",
6260
AllowLeadingWildcard = true,
6361
MaximumDeterminizedStates = 2,
6462
Escape = true,
@@ -83,10 +81,9 @@ new QueryStringQuery
8381
"_name": "named_query",
8482
"boost": 1.1,
8583
"query": "hello world",
86-
"default_field": "description",
8784
"default_operator": "or",
8885
"analyzer": "standard",
89-
"quote_analyzer": "quote-an",
86+
"quote_analyzer": "keyword",
9087
"allow_leading_wildcard": true,
9188
"fuzzy_max_expansions": 3,
9289
"fuzziness": "AUTO",

docs/query-dsl/geo/bounding-box/geo-bounding-box-query-usage.asciidoc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ q
2323
.GeoBoundingBox(g => g
2424
.Boost(1.1)
2525
.Name("named_query")
26-
.Field(p => p.Location)
26+
.Field(p => p.LocationPoint)
2727
.BoundingBox(b => b
2828
.TopLeft(34, -34)
2929
.BottomRight(-34, 34)
@@ -41,7 +41,7 @@ new GeoBoundingBoxQuery
4141
{
4242
Boost = 1.1,
4343
Name = "named_query",
44-
Field = Infer.Field<Project>(p => p.Location),
44+
Field = Infer.Field<Project>(p => p.LocationPoint),
4545
BoundingBox = new Nest.BoundingBox
4646
{
4747
TopLeft = new GeoLocation(34, -34),
@@ -61,7 +61,7 @@ new GeoBoundingBoxQuery
6161
"validation_method": "strict",
6262
"_name": "named_query",
6363
"boost": 1.1,
64-
"location": {
64+
"locationPoint": {
6565
"top_left": {
6666
"lat": 34.0,
6767
"lon": -34.0
@@ -83,9 +83,9 @@ q
8383
.GeoBoundingBox(g => g
8484
.Boost(1.1)
8585
.Name("named_query")
86-
.Field(p => p.Location)
86+
.Field(p => p.LocationPoint)
8787
.BoundingBox(b => b
88-
.WellKnownText("BBOX (34, -34, -34, 34)")
88+
.WellKnownText("BBOX (-34, 34, 34, -34)")
8989
)
9090
.ValidationMethod(GeoValidationMethod.Strict)
9191
.Type(GeoExecution.Indexed)
@@ -100,10 +100,10 @@ new GeoBoundingBoxQuery
100100
{
101101
Boost = 1.1,
102102
Name = "named_query",
103-
Field = Infer.Field<Project>(p => p.Location),
103+
Field = Infer.Field<Project>(p => p.LocationPoint),
104104
BoundingBox = new Nest.BoundingBox
105105
{
106-
WellKnownText = "BBOX (34, -34, -34, 34)"
106+
WellKnownText = "BBOX (-34, 34, 34, -34)"
107107
},
108108
Type = GeoExecution.Indexed,
109109
ValidationMethod = GeoValidationMethod.Strict
@@ -119,8 +119,8 @@ new GeoBoundingBoxQuery
119119
"validation_method": "strict",
120120
"_name": "named_query",
121121
"boost": 1.1,
122-
"location": {
123-
"wkt": "BBOX (34, -34, -34, 34)"
122+
"locationPoint": {
123+
"wkt": "BBOX (-34, 34, 34, -34)"
124124
}
125125
}
126126
}

docs/query-dsl/geo/distance/geo-distance-query-usage.asciidoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ q
2323
.GeoDistance(g => g
2424
.Boost(1.1)
2525
.Name("named_query")
26-
.Field(p => p.Location)
26+
.Field(p => p.LocationPoint)
2727
.DistanceType(GeoDistanceType.Arc)
2828
.Location(34, -34)
2929
.Distance("200.0m")
@@ -39,7 +39,7 @@ new GeoDistanceQuery
3939
{
4040
Boost = 1.1,
4141
Name = "named_query",
42-
Field = Infer.Field<Project>(p => p.Location),
42+
Field = Infer.Field<Project>(p => p.LocationPoint),
4343
DistanceType = GeoDistanceType.Arc,
4444
Location = new GeoLocation(34, -34),
4545
Distance = "200.0m",
@@ -57,7 +57,7 @@ new GeoDistanceQuery
5757
"distance": "200.0m",
5858
"distance_type": "arc",
5959
"validation_method": "ignore_malformed",
60-
"location": {
60+
"locationPoint": {
6161
"lat": 34.0,
6262
"lon": -34.0
6363
}

0 commit comments

Comments
 (0)