Skip to content

Commit 8dbde3b

Browse files
elasticsearchmachineSamiul-TheSoccerFan
authored andcommitted
[CI] Auto commit changes from spotless
1 parent c538fe9 commit 8dbde3b

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

x-pack/plugin/inference/src/internalClusterTest/java/org/elasticsearch/xpack/inference/integration/SemanticTextIndexVersionIT.java

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
import java.io.IOException;
3333
import java.util.Collection;
3434
import java.util.HashMap;
35-
import java.util.Map;
3635
import java.util.List;
36+
import java.util.Map;
3737
import java.util.Set;
3838
import java.util.stream.Collectors;
3939

@@ -50,7 +50,8 @@ public class SemanticTextIndexVersionIT extends ESIntegTestCase {
5050
@Before
5151
public void setup() throws Exception {
5252
Utils.storeSparseModel(client());
53-
availableVersions = IndexVersionUtils.allReleasedVersions().stream()
53+
availableVersions = IndexVersionUtils.allReleasedVersions()
54+
.stream()
5455
.filter((version -> version.onOrAfter(SEMANTIC_TEXT_INTRODUCED_VERSION)))
5556
.collect(Collectors.toSet());
5657

@@ -64,10 +65,7 @@ protected boolean forbidPrivateIndexSettings() {
6465

6566
@Override
6667
protected Settings nodeSettings(int nodeOrdinal, Settings otherSettings) {
67-
return Settings.builder()
68-
.put(otherSettings)
69-
.put(LicenseSettings.SELF_GENERATED_LICENSE_TYPE.getKey(), "trial")
70-
.build();
68+
return Settings.builder().put(otherSettings).put(LicenseSettings.SELF_GENERATED_LICENSE_TYPE.getKey(), "trial").build();
7169
}
7270

7371
@Override
@@ -79,10 +77,7 @@ protected Collection<Class<? extends Plugin>> nodePlugins() {
7977
* Generate settings for an index with a specific version.
8078
*/
8179
private Settings getIndexSettingsWithVersion(IndexVersion version) {
82-
return Settings.builder()
83-
.put(indexSettings())
84-
.put("index.version.created", version)
85-
.build();
80+
return Settings.builder().put(indexSettings()).put("index.version.created", version).build();
8681
}
8782

8883
/**
@@ -113,11 +108,18 @@ public void test() throws Exception {
113108

114109
// Test index creation
115110
assertTrue("Index " + indexName + " should exist", indexExists(indexName));
116-
assertEquals("Index version should match",
111+
assertEquals(
112+
"Index version should match",
117113
version.id(),
118-
client().admin().indices().prepareGetSettings(TimeValue.THIRTY_SECONDS, indexName)
119-
.get().getIndexToSettings().get(indexName)
120-
.getAsVersionId("index.version.created", IndexVersion::fromId).id());
114+
client().admin()
115+
.indices()
116+
.prepareGetSettings(TimeValue.THIRTY_SECONDS, indexName)
117+
.get()
118+
.getIndexToSettings()
119+
.get(indexName)
120+
.getAsVersionId("index.version.created", IndexVersion::fromId)
121+
.id()
122+
);
121123

122124
// Test update mapping
123125
XContentBuilder mapping = XContentFactory.jsonBuilder()
@@ -130,20 +132,17 @@ public void test() throws Exception {
130132
.endObject()
131133
.endObject();
132134

133-
assertAcked(client().admin().indices().preparePutMapping(indexName)
134-
.setSource(mapping)
135-
.get());
135+
assertAcked(client().admin().indices().preparePutMapping(indexName).setSource(mapping).get());
136136

137137
// Test data ingestion
138-
String[] text = new String[] {"inference test", "another inference test"};
138+
String[] text = new String[] { "inference test", "another inference test" };
139139

140140
DocWriteResponse response = client().prepareIndex(indexName).setSource(Map.of("semantic_field", text)).get();
141141

142142
assertEquals("Document should be created", "created", response.getResult().toString().toLowerCase());
143143

144144
client().admin().indices().refresh(new RefreshRequest(indexName)).get();
145145

146-
147146
// Simple search
148147
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder().trackTotalHits(true);
149148
SearchResponse searchResponse = client().search(new SearchRequest(indexName).source(sourceBuilder)).get();
@@ -156,21 +155,23 @@ public void test() throws Exception {
156155
// Search with query
157156
SearchResponse searchWithQueryResponse = null;
158157
if (version.after(SEMANTIC_TEXT_NEW_FORMAT)) {
159-
searchWithQueryResponse = client().search(new SearchRequest(indexName)
160-
.source(sourceBuilder.query(QueryBuilders.matchQuery("semantic_field", "another inference test"))))
161-
.get();
158+
searchWithQueryResponse = client().search(
159+
new SearchRequest(indexName).source(
160+
sourceBuilder.query(QueryBuilders.matchQuery("semantic_field", "another inference test"))
161+
)
162+
).get();
162163
} else {
163164
String semanticQuery = """
164-
{
165-
"semantic": {
166-
"field": "semantic_field",
167-
"query": "inference"
168-
}
169-
}
170-
""";
171-
searchWithQueryResponse = client().search(new SearchRequest(indexName)
172-
.source(sourceBuilder.query(new SemanticQueryBuilder("semantic_field", "inference test"))))
173-
.get();
165+
{
166+
"semantic": {
167+
"field": "semantic_field",
168+
"query": "inference"
169+
}
170+
}
171+
""";
172+
searchWithQueryResponse = client().search(
173+
new SearchRequest(indexName).source(sourceBuilder.query(new SemanticQueryBuilder("semantic_field", "inference test")))
174+
).get();
174175
}
175176

176177
try {
@@ -179,7 +180,6 @@ public void test() throws Exception {
179180
searchResponse.decRef();
180181
}
181182

182-
183183
}
184184
}
185185

0 commit comments

Comments
 (0)