Skip to content
This repository was archived by the owner on May 24, 2024. It is now read-only.

Commit 782e168

Browse files
committed
Update to ES 7.7.0, fix javadoc.
1 parent 7dcf47e commit 782e168

File tree

6 files changed

+75
-78
lines changed

6 files changed

+75
-78
lines changed

build.gradle

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11

22
// This plugin's version (typically must match that of ES).
3-
version = '7.6.2'
3+
version = '7.7.0'
44
group = 'org.carrot2'
55

66
buildscript {
77
ext {
8-
version_es = '7.6.2'
8+
version_es = '7.7.0'
99
version_c2 = 'org.carrot2:carrot2-core:4.0.1'
1010
}
1111

@@ -54,9 +54,9 @@ dependencies {
5454
}
5555
compile version_c2
5656

57-
testCompile "com.fasterxml.jackson.core:jackson-core:2.8.11"
58-
testCompile "com.fasterxml.jackson.core:jackson-annotations:2.8.11"
59-
testCompile "com.fasterxml.jackson.core:jackson-databind:2.8.11"
57+
testCompile "com.fasterxml.jackson.core:jackson-core:2.10.4"
58+
testCompile "com.fasterxml.jackson.core:jackson-annotations:2.10.4"
59+
testCompile "com.fasterxml.jackson.core:jackson-databind:2.10.4"
6060

6161
testCompile "org.assertj:assertj-core:3.12.0"
6262
testCompile "org.elasticsearch.client:transport:" + version_es
@@ -109,6 +109,11 @@ bundlePlugin {
109109
})
110110
}
111111

112+
// Disable POM validation inside ES infrastructure.
113+
tasks.matching {it.path in [":validateMavenPom", ":validateNebulaPom"]}.all { task ->
114+
task.enabled = false
115+
}
116+
112117
// Configure publishing.
113118
configure(rootProject) {
114119
apply plugin: 'maven-publish'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

src/main/java/org/carrot2/elasticsearch/ClusteringAction.java

Lines changed: 51 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
import org.elasticsearch.common.xcontent.XContentType;
4444
import org.elasticsearch.rest.BaseRestHandler;
4545
import org.elasticsearch.rest.BytesRestResponse;
46-
import org.elasticsearch.rest.RestController;
4746
import org.elasticsearch.rest.RestRequest;
4847
import org.elasticsearch.rest.action.search.RestSearchAction;
4948
import org.elasticsearch.search.SearchHit;
@@ -114,7 +113,6 @@ public static class ClusteringActionRequest extends ActionRequest implements Ind
114113
public static String JSON_ALGORITHM = "algorithm";
115114
public static String JSON_ATTRIBUTES = "attributes";
116115
public static String JSON_SEARCH_REQUEST = "search_request";
117-
public static String JSON_INCLUDE_HITS = "include_hits";
118116
public static String JSON_MAX_HITS = "max_hits";
119117
public static String JSON_CREATE_UNGROUPED_CLUSTER = "create_ungrouped";
120118
public static String JSON_LANGUAGE = "language";
@@ -143,6 +141,9 @@ public ClusteringActionRequest setSearchRequest(SearchRequest searchRequest) {
143141

144142
/**
145143
* @see #setSearchRequest(SearchRequest)
144+
*
145+
* @param builder The search builder
146+
* @return Returns same object for chaining.
146147
*/
147148
public ClusteringActionRequest setSearchRequest(SearchRequestBuilder builder) {
148149
return setSearchRequest(builder.request());
@@ -192,6 +193,8 @@ public ClusteringActionRequest setQueryHint(String queryHint) {
192193

193194
/**
194195
* @see #setQueryHint(String)
196+
*
197+
* @return Query hint
195198
*/
196199
public String getQueryHint() {
197200
return queryHint;
@@ -200,6 +203,9 @@ public String getQueryHint() {
200203
/**
201204
* Sets the identifier of the clustering algorithm to use. If <code>null</code>, the default
202205
* algorithm will be used (depending on what's available).
206+
*
207+
* @param algorithm identifier of the clustering algorithm to use.
208+
* @return Same object for chaining
203209
*/
204210
public ClusteringActionRequest setAlgorithm(String algorithm) {
205211
this.algorithm = algorithm;
@@ -208,42 +214,21 @@ public ClusteringActionRequest setAlgorithm(String algorithm) {
208214

209215
/**
210216
* @see #setAlgorithm
217+
*
218+
* @return The current algorithm to use for clustering
211219
*/
212220
public String getAlgorithm() {
213221
return algorithm;
214222
}
215223

216-
/**
217-
* @see #getIncludeHits
218-
* @deprecated Use {@link #setMaxHits} and set it to zero instead.
219-
*/
220-
@Deprecated()
221-
public boolean getIncludeHits() {
222-
return maxHits > 0;
223-
}
224-
225-
/**
226-
* Sets whether to include hits with clustering results. If only cluster labels
227-
* are needed the hits may be omitted to save bandwidth.
228-
*
229-
* @deprecated Use {@link #setMaxHits} instead.
230-
*/
231-
@Deprecated()
232-
public ClusteringActionRequest setIncludeHits(boolean includeHits) {
233-
if (includeHits) {
234-
setMaxHits(Integer.MAX_VALUE);
235-
} else {
236-
setMaxHits(0);
237-
}
238-
return this;
239-
}
240-
241224
/**
242225
* Sets the maximum number of hits to return with the response. Setting this
243226
* value to zero will only return clusters, without any hits (can be used
244227
* to save bandwidth if only cluster labels are needed).
245228
* <p>
246229
* Set to {@link Integer#MAX_VALUE} to include all the hits.
230+
*
231+
* @param maxHits Maximum hits
247232
*/
248233
public void setMaxHits(int maxHits) {
249234
assert maxHits >= 0;
@@ -253,6 +238,8 @@ public void setMaxHits(int maxHits) {
253238
/**
254239
* Sets {@link #setMaxHits(int)} from a string. An empty string or null means
255240
* all hits should be included.
241+
*
242+
* @param value Maximum number of hits.
256243
*/
257244
public void setMaxHits(String value) {
258245
if (value == null || value.trim().isEmpty()) {
@@ -263,15 +250,18 @@ public void setMaxHits(String value) {
263250
}
264251

265252
/**
266-
* Returns the maximum number of hits to be returned as part of the response.
267-
* If equal to {@link Integer#MAX_VALUE}, then all hits will be returned.
253+
* @return Returns the maximum number of hits to be returned as part of the response. * If equal
254+
* to {@link Integer#MAX_VALUE}, then all hits will be returned.
268255
*/
269256
public int getMaxHits() {
270257
return maxHits;
271258
}
272259

273260
/**
274261
* Sets a map of runtime override attributes for clustering algorithms.
262+
*
263+
* @param map Clustering attributes to use.
264+
* @return Same object for chaining
275265
*/
276266
public ClusteringActionRequest setAttributes(Map<String, Object> map) {
277267
this.attributes = map;
@@ -280,13 +270,19 @@ public ClusteringActionRequest setAttributes(Map<String, Object> map) {
280270

281271
/**
282272
* @see #setAttributes(Map)
273+
*
274+
* @return Clustering algorithm attributes map
283275
*/
284276
public Map<String, Object> getAttributes() {
285277
return attributes;
286278
}
287279

288280
/**
289281
* Parses some {@link org.elasticsearch.common.xcontent.XContent} and fills in the request.
282+
*
283+
* @param source arg
284+
* @param xContentType arg
285+
* @param xContentRegistry arg
290286
*/
291287
@SuppressWarnings("unchecked")
292288
public void source(BytesReference source, XContentType xContentType, NamedXContentRegistry xContentRegistry) {
@@ -345,12 +341,6 @@ public void source(BytesReference source, XContentType xContentType, NamedXConte
345341
searchRequest.source(searchSourceBuilder);
346342
}
347343

348-
Object includeHits = asMap.get(JSON_INCLUDE_HITS);
349-
if (includeHits != null) {
350-
LogManager.getLogger(getClass()).warn("Request used deprecated 'include_hits' parameter.");
351-
setIncludeHits(Boolean.parseBoolean(includeHits.toString()));
352-
}
353-
354344
Object maxHits = asMap.get(JSON_MAX_HITS);
355345
if (maxHits != null) {
356346
setMaxHits(maxHits.toString());
@@ -381,6 +371,10 @@ private void parseFieldSpecs(Map<String, List<String>> fieldSpecs) {
381371
* Map a hit's field to a logical section of a document to be clustered (title, content or URL).
382372
*
383373
* @see LogicalField
374+
*
375+
* @param fieldName field name
376+
* @param logicalField logical field mapping.
377+
* @return Same object for chaining
384378
*/
385379
public ClusteringActionRequest addFieldMapping(String fieldName, LogicalField logicalField) {
386380
fieldMapping.add(new FieldMappingSpec(fieldName, logicalField, FieldSource.FIELD));
@@ -392,6 +386,10 @@ public ClusteringActionRequest addFieldMapping(String fieldName, LogicalField lo
392386
* to a logical section of a document to be clustered (title, content or URL).
393387
*
394388
* @see LogicalField
389+
*
390+
* @param sourceFieldName field name
391+
* @param logicalField logical field mapping.
392+
* @return Same object for chaining
395393
*/
396394
public ClusteringActionRequest addSourceFieldMapping(String sourceFieldName, LogicalField logicalField) {
397395
fieldMapping.add(new FieldMappingSpec(sourceFieldName, logicalField, FieldSource.SOURCE));
@@ -403,6 +401,10 @@ public ClusteringActionRequest addSourceFieldMapping(String sourceFieldName, Log
403401
* of a document to be clustered. This may be used to decrease the amount of information
404402
* passed to the clustering engine but also to "focus" the clustering engine on the context
405403
* of the query.
404+
*
405+
* @param fieldName field name
406+
* @param logicalField logical field mapping.
407+
* @return Same object for chaining
406408
*/
407409
public ClusteringActionRequest addHighlightedFieldMapping(String fieldName, LogicalField logicalField) {
408410
fieldMapping.add(new FieldMappingSpec(fieldName, logicalField, FieldSource.HIGHLIGHT));
@@ -413,6 +415,10 @@ public ClusteringActionRequest addHighlightedFieldMapping(String fieldName, Logi
413415
* Add a (valid!) field mapping specification to a logical field.
414416
*
415417
* @see FieldSource
418+
*
419+
* @param fieldSpec field specification
420+
* @param logicalField logical field mapping.
421+
* @return Same object for chaining
416422
*/
417423
public ClusteringActionRequest addFieldMappingSpec(String fieldSpec, LogicalField logicalField) {
418424
FieldSource.ParsedFieldSource pfs = FieldSource.parseSpec(fieldSpec);
@@ -569,18 +575,6 @@ public ClusteringActionRequestBuilder setSource(BytesReference content,
569575
return this;
570576
}
571577

572-
/**
573-
* @deprecated Use {@link #setMaxHits} instead.
574-
*/
575-
@Deprecated()
576-
public ClusteringActionRequestBuilder setIncludeHits(String includeHits) {
577-
if (includeHits != null)
578-
super.request.setIncludeHits(Boolean.parseBoolean(includeHits));
579-
else
580-
super.request.setIncludeHits(true);
581-
return this;
582-
}
583-
584578
public ClusteringActionRequestBuilder setMaxHits(int maxHits) {
585579
super.request.setMaxHits(maxHits);
586580
return this;
@@ -910,9 +904,6 @@ public void onResponse(SearchResponse response) {
910904
ClusteringActionResponse.Fields.Info.TOTAL_MILLIS,
911905
Long.toString(
912906
TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - tsSearchStart)));
913-
info.put(
914-
ClusteringActionResponse.Fields.Info.INCLUDE_HITS,
915-
Boolean.toString(clusteringRequest.getIncludeHits()));
916907
info.put(
917908
ClusteringActionResponse.Fields.Info.MAX_HITS,
918909
clusteringRequest.getMaxHits() == Integer.MAX_VALUE
@@ -1243,14 +1234,16 @@ public static class RestClusteringAction extends BaseRestHandler {
12431234
*/
12441235
public static String NAME = "_search_with_clusters";
12451236

1246-
public RestClusteringAction(RestController controller) {
1247-
controller.registerHandler(POST, "/" + NAME, this);
1248-
controller.registerHandler(POST, "/{index}/" + NAME, this);
1249-
controller.registerHandler(POST, "/{index}/{type}/" + NAME, this);
1250-
1251-
controller.registerHandler(GET, "/" + NAME, this);
1252-
controller.registerHandler(GET, "/{index}/" + NAME, this);
1253-
controller.registerHandler(GET, "/{index}/{type}/" + NAME, this);
1237+
@Override
1238+
public List<Route> routes() {
1239+
return Arrays.asList(
1240+
new Route(POST, "/" + NAME),
1241+
new Route(POST, "/{index}/" + NAME),
1242+
new Route(POST, "/{index}/{type}/" + NAME),
1243+
new Route(GET, "/" + NAME),
1244+
new Route(GET, "/{index}/" + NAME),
1245+
new Route(GET, "/{index}/{type}/" + NAME)
1246+
);
12541247
}
12551248

12561249
@Override
@@ -1368,10 +1361,6 @@ private void fillFromGetRequest(
13681361
actionBuilder.setAlgorithm(request.param(ClusteringActionRequest.JSON_ALGORITHM));
13691362
}
13701363

1371-
if (request.hasParam(ClusteringActionRequest.JSON_INCLUDE_HITS)) {
1372-
actionBuilder.setIncludeHits(request.param(ClusteringActionRequest.JSON_INCLUDE_HITS));
1373-
}
1374-
13751364
if (request.hasParam(ClusteringActionRequest.JSON_MAX_HITS)) {
13761365
actionBuilder.setMaxHits(request.param(ClusteringActionRequest.JSON_MAX_HITS));
13771366
}

src/main/java/org/carrot2/elasticsearch/ClusteringContext.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ protected void doStart() throws ElasticsearchException {
146146
}
147147
}
148148

149-
/** Return a list of available algorithm component identifiers. */
149+
/**
150+
* @return Return a list of available algorithm component identifiers.
151+
*/
150152
public LinkedHashMap<String, ClusteringAlgorithmProvider> getAlgorithms() {
151153
return algorithmProviders;
152154
}

src/main/java/org/carrot2/elasticsearch/ClusteringPlugin.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,17 @@ public List<RestHandler> getRestHandlers(Settings settings, RestController restC
8686
IndexNameExpressionResolver indexNameExpressionResolver,
8787
Supplier<DiscoveryNodes> nodesInCluster) {
8888
return Arrays.asList(
89-
new ClusteringAction.RestClusteringAction(restController),
90-
new ListAlgorithmsAction.RestListAlgorithmsAction(restController));
89+
new ClusteringAction.RestClusteringAction(),
90+
new ListAlgorithmsAction.RestListAlgorithmsAction());
9191
}
9292

9393
@Override
9494
public Collection<Object> createComponents(Client client, ClusterService clusterService,
9595
ThreadPool threadPool, ResourceWatcherService resourceWatcherService,
9696
ScriptService scriptService, NamedXContentRegistry xContentRegistry,
9797
Environment environment, NodeEnvironment nodeEnvironment,
98-
NamedWriteableRegistry namedWriteableRegistry) {
98+
NamedWriteableRegistry namedWriteableRegistry,
99+
IndexNameExpressionResolver indexNameExpressionResolver) {
99100
List<Object> components = new ArrayList<>();
100101
if (pluginEnabled && !transportClient) {
101102
components.add(new ClusteringContext(environment,

src/main/java/org/carrot2/elasticsearch/ListAlgorithmsAction.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import org.elasticsearch.common.xcontent.XContentBuilder;
2121
import org.elasticsearch.rest.BaseRestHandler;
2222
import org.elasticsearch.rest.BytesRestResponse;
23-
import org.elasticsearch.rest.RestController;
2423
import org.elasticsearch.rest.RestRequest;
2524
import org.elasticsearch.rest.RestRequest.Method;
2625
import org.elasticsearch.rest.RestStatus;
@@ -202,11 +201,12 @@ public static class RestListAlgorithmsAction extends BaseRestHandler {
202201

203202
protected Logger logger = LogManager.getLogger(getClass());
204203

205-
public RestListAlgorithmsAction(
206-
RestController controller) {
207-
208-
controller.registerHandler(Method.POST, "/" + NAME, this);
209-
controller.registerHandler(Method.GET, "/" + NAME, this);
204+
@Override
205+
public List<Route> routes() {
206+
return Arrays.asList(
207+
new Route(Method.POST, "/" + NAME),
208+
new Route(Method.GET, "/" + NAME)
209+
);
210210
}
211211

212212
@Override

0 commit comments

Comments
 (0)