diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/analyze/AnalyzeRequestBuilder.java b/core/src/main/java/org/elasticsearch/action/admin/indices/analyze/AnalyzeRequestBuilder.java index 344681b997e..5070862ed69 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/analyze/AnalyzeRequestBuilder.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/analyze/AnalyzeRequestBuilder.java @@ -113,7 +113,7 @@ public class AnalyzeRequestBuilder extends SingleShardOperationRequestBuilder attributes; private String type; AnalyzeToken() { } - public AnalyzeToken(String term, int position, int startOffset, int endOffset, String type, - Map attributes) { + public AnalyzeToken(String term, int position, int startOffset, int endOffset, int positionLength, + String type, Map attributes) { this.term = term; this.position = position; this.startOffset = startOffset; this.endOffset = endOffset; + this.positionLength = positionLength; this.type = type; this.attributes = attributes; } @@ -71,6 +73,10 @@ public class AnalyzeResponse extends ActionResponse implements Iterable 1) { + builder.field(Fields.POSITION_LENGTH, positionLength); + } if (attributes != null && !attributes.isEmpty()) { for (Map.Entry entity : attributes.entrySet()) { builder.field(entity.getKey(), entity.getValue()); @@ -108,6 +117,14 @@ public class AnalyzeResponse extends ActionResponse implements Iterable) in.readGenericValue(); @@ -120,6 +137,9 @@ public class AnalyzeResponse extends ActionResponse implements Iterable 1 ? positionLength : null); + } out.writeOptionalString(type); if (out.getVersion().onOrAfter(Version.V_2_2_0)) { out.writeGenericValue(attributes); @@ -208,6 +228,7 @@ public class AnalyzeResponse extends ActionResponse implements Iterable 0) { lastPosition = lastPosition + increment; } - tokens.add(new AnalyzeResponse.AnalyzeToken(term.toString(), lastPosition, lastOffset + offset.startOffset(), lastOffset + offset.endOffset(), type.type(), null)); + tokens.add(new AnalyzeResponse.AnalyzeToken(term.toString(), lastPosition, lastOffset + offset.startOffset(), + lastOffset + offset.endOffset(), posLen.getPositionLength(), type.type(), null)); } stream.end(); @@ -381,6 +384,7 @@ public class TransportAnalyzeAction extends TransportSingleShardAction