Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use alternate example data in OpenSearch test cases. #454

Merged
merged 3 commits into from
Mar 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1730,7 +1730,7 @@ public void testValidateQuery() throws IOException{
QueryBuilder builder = QueryBuilders
.boolQuery()
.must(QueryBuilders.queryStringQuery("*:*"))
.filter(QueryBuilders.termQuery("user", "kimchy"));
.filter(QueryBuilders.termQuery("user", "foobar"));
ValidateQueryRequest request = new ValidateQueryRequest(index).query(builder);
request.explain(randomBoolean());
ValidateQueryResponse response = execute(request, highLevelClient().indices()::validateQuery,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void testIndex() throws Exception {
{
//tag::index-request-map
Map<String, Object> jsonMap = new HashMap<>();
jsonMap.put("user", "kimchy");
jsonMap.put("user", "foobar");
jsonMap.put("postDate", new Date());
jsonMap.put("message", "trying out OpenSearch");
IndexRequest indexRequest = new IndexRequest("posts")
Expand All @@ -129,7 +129,7 @@ public void testIndex() throws Exception {
XContentBuilder builder = XContentFactory.jsonBuilder();
builder.startObject();
{
builder.field("user", "kimchy");
builder.field("user", "foobar");
builder.timeField("postDate", new Date());
builder.field("message", "trying out OpenSearch");
}
Expand All @@ -144,7 +144,7 @@ public void testIndex() throws Exception {
//tag::index-request-shortcut
IndexRequest indexRequest = new IndexRequest("posts")
.id("1")
.source("user", "kimchy",
.source("user", "foobar",
"postDate", new Date(),
"message", "trying out OpenSearch"); // <1>
//end::index-request-shortcut
Expand All @@ -156,7 +156,7 @@ public void testIndex() throws Exception {
IndexRequest request = new IndexRequest("posts"); // <1>
request.id("1"); // <2>
String jsonString = "{" +
"\"user\":\"kimchy\"," +
"\"user\":\"foobar\"," +
"\"postDate\":\"2013-01-30\"," +
"\"message\":\"trying out OpenSearch\"" +
"}";
Expand Down Expand Up @@ -838,7 +838,7 @@ public void testReindex() throws Exception {
request.setScript(
new Script(
ScriptType.INLINE, "painless",
"if (ctx._source.user == 'kimchy') {ctx._source.likes++;}",
"if (ctx._source.user == 'foobar') {ctx._source.likes++;}",
Collections.emptyMap())); // <1>
// end::reindex-request-script
HttpHost host = getClusterHosts().get(0);
Expand Down Expand Up @@ -903,7 +903,7 @@ public void testReindex() throws Exception {

// These cannot be set with a remote set, so its set here instead for the docs
// tag::reindex-request-query
request.setSourceQuery(new TermQueryBuilder("user", "kimchy")); // <1>
request.setSourceQuery(new TermQueryBuilder("user", "foobar")); // <1>
// end::reindex-request-query
// tag::reindex-request-slices
request.setSlices(2); // <1>
Expand Down Expand Up @@ -1021,7 +1021,7 @@ public void testUpdateByQuery() throws Exception {
request.setConflicts("proceed"); // <1>
// end::update-by-query-request-conflicts
// tag::update-by-query-request-query
request.setQuery(new TermQueryBuilder("user", "kimchy")); // <1>
request.setQuery(new TermQueryBuilder("user", "foobar")); // <1>
// end::update-by-query-request-query
// tag::update-by-query-request-maxDocs
request.setMaxDocs(10); // <1>
Expand All @@ -1036,7 +1036,7 @@ public void testUpdateByQuery() throws Exception {
request.setScript(
new Script(
ScriptType.INLINE, "painless",
"if (ctx._source.user == 'kimchy') {ctx._source.likes++;}",
"if (ctx._source.user == 'foobar') {ctx._source.likes++;}",
Collections.emptyMap())); // <1>
// end::update-by-query-request-script
// tag::update-by-query-request-timeout
Expand Down Expand Up @@ -1143,7 +1143,7 @@ public void testDeleteByQuery() throws Exception {
request.setConflicts("proceed"); // <1>
// end::delete-by-query-request-conflicts
// tag::delete-by-query-request-query
request.setQuery(new TermQueryBuilder("user", "kimchy")); // <1>
request.setQuery(new TermQueryBuilder("user", "foobar")); // <1>
// end::delete-by-query-request-query
// tag::delete-by-query-request-maxDocs
request.setMaxDocs(10); // <1>
Expand Down Expand Up @@ -1246,7 +1246,7 @@ public void testGet() throws Exception {
assertEquals(200, response.getStatusLine().getStatusCode());

IndexRequest indexRequest = new IndexRequest("posts").id("1")
.source("user", "kimchy",
.source("user", "foobar",
"postDate", new Date(),
"message", "trying out OpenSearch");
IndexResponse indexResponse = client.index(indexRequest, RequestOptions.DEFAULT);
Expand Down Expand Up @@ -1312,7 +1312,7 @@ public void testGet() throws Exception {
GetResponse getResponse = client.get(request, RequestOptions.DEFAULT);
Map<String, Object> sourceAsMap = getResponse.getSourceAsMap();
assertEquals(2, sourceAsMap.size());
assertEquals("kimchy", sourceAsMap.get("user"));
assertEquals("foobar", sourceAsMap.get("user"));
assertTrue(sourceAsMap.containsKey("postDate"));
}
{
Expand Down Expand Up @@ -1419,7 +1419,7 @@ public void testGetSource() throws Exception {
assertEquals(200, response.getStatusLine().getStatusCode());

IndexRequest indexRequest = new IndexRequest("posts").id("1")
.source("user", "kimchy",
.source("user", "foobar",
"postDate", new Date(),
"message", "trying out OpenSearch");
IndexResponse indexResponse = client.index(indexRequest, RequestOptions.DEFAULT);
Expand Down Expand Up @@ -1462,7 +1462,7 @@ public void testGetSource() throws Exception {
// end::get-source-response

Map<String, Object> expectSource = new HashMap<>();
expectSource.put("user", "kimchy");
expectSource.put("user", "foobar");
expectSource.put("message", "trying out OpenSearch");
assertEquals(expectSource, source);
}
Expand Down Expand Up @@ -1651,7 +1651,7 @@ public void testTermVectors() throws Exception {
.endObject());
CreateIndexResponse authorsResponse = client.indices().create(authorsRequest, RequestOptions.DEFAULT);
assertTrue(authorsResponse.isAcknowledged());
client.index(new IndexRequest("index").id("1").source("user", "kimchy"), RequestOptions.DEFAULT);
client.index(new IndexRequest("index").id("1").source("user", "foobar"), RequestOptions.DEFAULT);
Response refreshResponse = client().performRequest(new Request("POST", "/authors/_refresh"));
assertEquals(200, refreshResponse.getStatusLine().getStatusCode());

Expand Down Expand Up @@ -1782,8 +1782,8 @@ public void testMultiTermVectors() throws Exception {
.endObject());
CreateIndexResponse authorsResponse = client.indices().create(authorsRequest, RequestOptions.DEFAULT);
assertTrue(authorsResponse.isAcknowledged());
client.index(new IndexRequest("index").id("1").source("user", "kimchy"), RequestOptions.DEFAULT);
client.index(new IndexRequest("index").id("2").source("user", "s1monw"), RequestOptions.DEFAULT);
client.index(new IndexRequest("index").id("1").source("user", "foobar"), RequestOptions.DEFAULT);
client.index(new IndexRequest("index").id("2").source("user", "baz"), RequestOptions.DEFAULT);
Response refreshResponse = client().performRequest(new Request("POST", "/authors/_refresh"));
assertEquals(200, refreshResponse.getStatusLine().getStatusCode());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ public void testCreateIndex() throws IOException {

request = new CreateIndexRequest("twitter5");
// tag::create-index-request-aliases
request.alias(new Alias("twitter_alias").filter(QueryBuilders.termQuery("user", "kimchy"))); // <1>
request.alias(new Alias("twitter_alias").filter(QueryBuilders.termQuery("user", "foobar"))); // <1>
// end::create-index-request-aliases

// tag::create-index-request-timeout
Expand Down Expand Up @@ -2216,7 +2216,7 @@ public void testPutTemplate() throws Exception {
}

// tag::put-template-request-aliases
request.alias(new Alias("twitter_alias").filter(QueryBuilders.termQuery("user", "kimchy"))); // <1>
request.alias(new Alias("twitter_alias").filter(QueryBuilders.termQuery("user", "foobar"))); // <1>
request.alias(new Alias("{index}_alias").searchRouting("xyz")); // <2>
// end::put-template-request-aliases

Expand Down Expand Up @@ -2763,7 +2763,7 @@ public void testValidateQuery() throws IOException, InterruptedException {
QueryBuilder builder = QueryBuilders
.boolQuery() // <1>
.must(QueryBuilders.queryStringQuery("*:*"))
.filter(QueryBuilders.termQuery("user", "kimchy"));
.filter(QueryBuilders.termQuery("user", "foobar"));
request.query(builder); // <2>
// end::indices-validate-query-request-query

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,31 +102,31 @@ public void testBool() {
public void testBoosting() {
// tag::boosting
boostingQuery(
termQuery("name","kimchy"), // <1>
termQuery("name","dadoonet")) // <2>
termQuery("name","foobar"), // <1>
termQuery("name","qux")) // <2>
.negativeBoost(0.2f); // <3>
// end::boosting
}

public void testCommonTerms() {
// tag::common_terms
commonTermsQuery("name", // <1>
"kimchy"); // <2>
"foobar"); // <2>
// end::common_terms
}

public void testConstantScore() {
// tag::constant_score
constantScoreQuery(
termQuery("name","kimchy")) // <1>
termQuery("name","foobar")) // <1>
.boost(2.0f); // <2>
// end::constant_score
}

public void testDisMax() {
// tag::dis_max
disMaxQuery()
.add(termQuery("name", "kimchy")) // <1>
.add(termQuery("name", "foobar")) // <1>
.add(termQuery("name", "opensearch")) // <2>
.boost(1.2f) // <3>
.tieBreaker(0.7f); // <4>
Expand All @@ -143,7 +143,7 @@ public void testFunctionScore() {
// tag::function_score
FilterFunctionBuilder[] functions = {
new FunctionScoreQueryBuilder.FilterFunctionBuilder(
matchQuery("name", "kimchy"), // <1>
matchQuery("name", "foobar"), // <1>
randomFunction()), // <2>
new FunctionScoreQueryBuilder.FilterFunctionBuilder(
exponentialDecayFunction("age", 0L, 1L)) // <3>
Expand All @@ -156,7 +156,7 @@ public void testFuzzy() {
// tag::fuzzy
fuzzyQuery(
"name", // <1>
"kimchy"); // <2>
"foobar"); // <2>
// end::fuzzy
}

Expand Down Expand Up @@ -251,7 +251,7 @@ public void testMatch() {
// tag::match
matchQuery(
"name", // <1>
"kimchy opensearch"); // <2>
"foobar opensearch"); // <2>
// end::match
}

Expand All @@ -269,7 +269,7 @@ public void testMoreLikeThis() {
public void testMultiMatch() {
// tag::multi_match
multiMatchQuery(
"kimchy opensearch", // <1>
"foobar opensearch", // <1>
"user", "message"); // <2>
// end::multi_match
}
Expand All @@ -295,7 +295,7 @@ public void testPrefix() {

public void testQueryString() {
// tag::query_string
queryStringQuery("+kimchy -opensearch");
queryStringQuery("+foobar -opensearch");
// end::query_string
}

Expand Down Expand Up @@ -344,7 +344,7 @@ public void testScript() {

public void testSimpleQueryString() {
// tag::simple_query_string
simpleQueryStringQuery("+kimchy -opensearch");
simpleQueryStringQuery("+foobar -opensearch");
// end::simple_query_string
}

Expand All @@ -361,7 +361,7 @@ public void testSpanContaining() {
public void testSpanFirst() {
// tag::span_first
spanFirstQuery(
spanTermQuery("user", "kimchy"), // <1>
spanTermQuery("user", "foobar"), // <1>
3 // <2>
);
// end::span_first
Expand Down Expand Up @@ -405,7 +405,7 @@ public void testSpanTerm() {
// tag::span_term
spanTermQuery(
"user", // <1>
"kimchy"); // <2>
"foobar"); // <2>
// end::span_term
}

Expand All @@ -423,7 +423,7 @@ public void testTerm() {
// tag::term
termQuery(
"name", // <1>
"kimchy"); // <2>
"foobar"); // <2>
// end::term
}

Expand All @@ -450,7 +450,7 @@ public void testWildcard() {

public void testWrapper() {
// tag::wrapper
String query = "{\"term\": {\"user\": \"kimchy\"}}"; // <1>
String query = "{\"term\": {\"user\": \"foobar\"}}"; // <1>
wrapperQuery(query);
// end::wrapper
}
Expand Down
Loading