Skip to content

Commit

Permalink
Merge branch 'main' into overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Nov 13, 2024
2 parents 84c6296 + adf7328 commit c936bc9
Show file tree
Hide file tree
Showing 7 changed files with 161 additions and 272 deletions.
3 changes: 0 additions & 3 deletions muted-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@ tests:
- class: org.elasticsearch.xpack.inference.TextEmbeddingCrudIT
method: testPutE5Small_withPlatformSpecificVariant
issue: https://github.com/elastic/elasticsearch/issues/113950
- class: org.elasticsearch.xpack.inference.InferenceCrudIT
method: testGet
issue: https://github.com/elastic/elasticsearch/issues/114135
- class: org.elasticsearch.smoketest.DocsClientYamlTestSuiteIT
method: test {yaml=reference/rest-api/usage/line_38}
issue: https://github.com/elastic/elasticsearch/issues/113694
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertResponse;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertResponses;
import static org.elasticsearch.xcontent.XContentFactory.jsonBuilder;
import static org.hamcrest.Matchers.hasKey;
import static org.hamcrest.Matchers.is;
Expand Down Expand Up @@ -136,14 +137,11 @@ public void testWildCardWithFieldsWhenDisabled() throws Exception {
assertAcked(prepareCreate("test").setMapping("_size", "enabled=false"));
final String source = "{\"f\":\"" + randomAlphaOfLengthBetween(1, 100) + "\"}";
indexRandom(true, prepareIndex("test").setId("1").setSource(source, XContentType.JSON));
assertResponse(
assertResponses(
response -> assertNull(response.getHits().getHits()[0].getFields().get("_size")),
prepareSearch("test").addFetchField("_size"),
response -> assertNull(response.getHits().getHits()[0].getFields().get("_size"))
);

assertResponse(
prepareSearch("test").addFetchField("*"),
response -> assertNull(response.getHits().getHits()[0].getFields().get("_size"))
prepareSearch("test").addStoredField("*")
);

assertResponse(
Expand All @@ -156,19 +154,11 @@ public void testWildCardWithFieldsWhenNotProvided() throws Exception {
assertAcked(prepareCreate("test"));
final String source = "{\"f\":\"" + randomAlphaOfLengthBetween(1, 100) + "\"}";
indexRandom(true, prepareIndex("test").setId("1").setSource(source, XContentType.JSON));
assertResponse(
assertResponses(
response -> assertNull(response.getHits().getHits()[0].getFields().get("_size")),
prepareSearch("test").addFetchField("_size"),
response -> assertNull(response.getHits().getHits()[0].getFields().get("_size"))
);

assertResponse(
prepareSearch("test").addFetchField("*"),
response -> assertNull(response.getHits().getHits()[0].getFields().get("_size"))
);

assertResponse(
prepareSearch("test").addStoredField("*"),
response -> assertNull(response.getHits().getHits()[0].getFields().get("_size"))
prepareSearch("test").addStoredField("*")
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailuresAndResponse;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertResponse;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertResponses;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchHitsWithoutFailures;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSecondHit;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.hasId;
Expand Down Expand Up @@ -772,26 +773,21 @@ public void testCrossFieldMode() throws ExecutionException, InterruptedException
);
// counter example
assertHitCount(
0L,
prepareSearch("test").setQuery(
randomizeType(
multiMatchQuery("captain america marvel hero", "first_name", "last_name", "category").type(
randomBoolean() ? MultiMatchQueryBuilder.Type.CROSS_FIELDS : MultiMatchQueryBuilder.DEFAULT_TYPE
).operator(Operator.AND)
)
),
0L
);

// counter example
assertHitCount(
prepareSearch("test").setQuery(
randomizeType(
multiMatchQuery("captain america marvel hero", "first_name", "last_name", "category").type(
randomBoolean() ? MultiMatchQueryBuilder.Type.CROSS_FIELDS : MultiMatchQueryBuilder.DEFAULT_TYPE
).operator(Operator.AND)
)
),
0L
)
);

// test if boosts work
Expand Down Expand Up @@ -828,40 +824,21 @@ public void testCrossFieldMode() throws ExecutionException, InterruptedException
}
);
// Test group based on numeric fields
assertResponse(
assertResponses(response -> {
assertHitCount(response, 1L);
assertFirstHit(response, hasId("theone"));
},
prepareSearch("test").setQuery(randomizeType(multiMatchQuery("15", "skill").type(MultiMatchQueryBuilder.Type.CROSS_FIELDS))),
response -> {
assertHitCount(response, 1L);
assertFirstHit(response, hasId("theone"));
}
);
assertResponse(
prepareSearch("test").setQuery(
randomizeType(multiMatchQuery("15", "skill", "first_name").type(MultiMatchQueryBuilder.Type.CROSS_FIELDS))
),
response -> {
assertHitCount(response, 1L);
assertFirstHit(response, hasId("theone"));
}
);
// Two numeric fields together caused trouble at one point!
assertResponse(
// Two numeric fields together caused trouble at one point!
prepareSearch("test").setQuery(
randomizeType(multiMatchQuery("15", "int-field", "skill").type(MultiMatchQueryBuilder.Type.CROSS_FIELDS))
),
response -> {
assertHitCount(response, 1L);
assertFirstHit(response, hasId("theone"));
}
);
assertResponse(
prepareSearch("test").setQuery(
randomizeType(multiMatchQuery("15", "int-field", "first_name", "skill").type(MultiMatchQueryBuilder.Type.CROSS_FIELDS))
),
response -> {
assertHitCount(response, 1L);
assertFirstHit(response, hasId("theone"));
}
)
);
assertResponse(
prepareSearch("test").setQuery(
Expand Down
Loading

0 comments on commit c936bc9

Please sign in to comment.