diff --git a/docs/reference/indices/analyze.asciidoc b/docs/reference/indices/analyze.asciidoc index 03af74b416a..a9712d6c9a2 100644 --- a/docs/reference/indices/analyze.asciidoc +++ b/docs/reference/indices/analyze.asciidoc @@ -48,11 +48,3 @@ mapping for `obj1.field1` (and if not, the default index analyzer). Also, the text can be provided as part of the request body, and not as a parameter. - -[float] -[[format]] -=== Format - -By default, the format the tokens are returned in are in json and its -called `detailed`. The `text` format value provides the analyzed data in -a text stream that is a bit more readable. diff --git a/src/main/java/org/elasticsearch/action/admin/indices/analyze/AnalyzeResponse.java b/src/main/java/org/elasticsearch/action/admin/indices/analyze/AnalyzeResponse.java index 0e6f529173d..1f89c32e789 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/analyze/AnalyzeResponse.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/analyze/AnalyzeResponse.java @@ -25,6 +25,7 @@ import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Streamable; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.common.xcontent.XContentBuilderString; import java.io.IOException; import java.util.ArrayList; @@ -119,37 +120,17 @@ public class AnalyzeResponse extends ActionResponse implements Iterable").append(token.getEndOffset()).append(":") - .append(token.getType()) - .append("]\n"); - } - builder.field("tokens", sb); + builder.startArray(Fields.TOKENS); + for (AnalyzeToken token : tokens) { + builder.startObject(); + builder.field(Fields.TOKEN, token.getTerm()); + builder.field(Fields.START_OFFSET, token.getStartOffset()); + builder.field(Fields.END_OFFSET, token.getEndOffset()); + builder.field(Fields.TYPE, token.getType()); + builder.field(Fields.POSITION, token.getPosition()); + builder.endObject(); } + builder.endArray(); return builder; } @@ -171,4 +152,13 @@ public class AnalyzeResponse extends ActionResponse implements Iterable