Skip to content

Commit

Permalink
XContent refactoring, closes #367.
Browse files Browse the repository at this point in the history
  • Loading branch information
kimchy committed Sep 12, 2010
1 parent 4822517 commit 38aeba4
Show file tree
Hide file tree
Showing 203 changed files with 844 additions and 1,466 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.elasticsearch.client.Client;
import org.elasticsearch.common.StopWatch;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.node.Node;

import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.common.xcontent.builder.TextXContentBuilder;
import org.elasticsearch.common.xcontent.builder.XContentBuilder;

import java.io.IOException;
import java.util.Map;
Expand Down Expand Up @@ -141,7 +140,7 @@ public CreateIndexRequest settings(String source) {
*/
public CreateIndexRequest settings(Map source) {
try {
TextXContentBuilder builder = XContentFactory.contentTextBuilder(XContentType.JSON);
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
builder.map(source);
settings(builder.string());
} catch (IOException e) {
Expand Down Expand Up @@ -192,7 +191,7 @@ public CreateIndexRequest mapping(String type, XContentBuilder source) {
*/
public CreateIndexRequest mapping(String type, Map source) {
try {
TextXContentBuilder builder = XContentFactory.contentTextBuilder(XContentType.JSON);
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
builder.map(source);
return mapping(type, builder.string());
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.common.xcontent.builder.TextXContentBuilder;
import org.elasticsearch.common.xcontent.builder.XContentBuilder;

import java.io.IOException;
import java.util.Map;
Expand Down Expand Up @@ -137,7 +136,7 @@ String source() {
*/
@Required public PutMappingRequest source(Map mappingSource) {
try {
TextXContentBuilder builder = XContentFactory.contentTextBuilder(XContentType.JSON);
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
builder.map(mappingSource);
return source(builder.string());
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.common.xcontent.builder.TextXContentBuilder;

import java.io.IOException;
import java.util.Map;
Expand Down Expand Up @@ -114,7 +114,7 @@ public UpdateSettingsRequest settings(String source) {
*/
public UpdateSettingsRequest settings(Map source) {
try {
TextXContentBuilder builder = XContentFactory.contentTextBuilder(XContentType.JSON);
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
builder.map(source);
settings(builder.string());
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@
import org.elasticsearch.common.io.FastByteArrayOutputStream;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.common.xcontent.builder.BinaryXContentBuilder;
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
import org.elasticsearch.index.query.QueryBuilder;

import javax.annotation.Nullable;
Expand Down Expand Up @@ -184,7 +183,7 @@ int querySourceLength() {
*/
@Required public CountRequest query(Map querySource) {
try {
BinaryXContentBuilder builder = XContentFactory.contentBinaryBuilder(contentType);
XContentBuilder builder = XContentFactory.contentBuilder(contentType);
builder.map(querySource);
return query(builder);
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.common.xcontent.builder.BinaryXContentBuilder;
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
import org.elasticsearch.index.query.QueryBuilder;

import java.io.IOException;
Expand Down Expand Up @@ -147,7 +146,7 @@ byte[] querySource() {
*/
@Required public DeleteByQueryRequest query(Map querySource) {
try {
BinaryXContentBuilder builder = XContentFactory.contentBinaryBuilder(contentType);
XContentBuilder builder = XContentFactory.contentBuilder(contentType);
builder.map(querySource);
return query(builder);
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
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.XContentFactory;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
import org.elasticsearch.rest.action.support.RestXContentBuilder;

import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.common.xcontent.builder.BinaryXContentBuilder;
import org.elasticsearch.common.xcontent.builder.XContentBuilder;

import java.io.IOException;
import java.util.Arrays;
Expand All @@ -49,8 +48,8 @@
* {@link #source(byte[])} to be set.
*
* <p>The source (content to index) can be set in its bytes form using ({@link #source(byte[])}),
* its string form ({@link #source(String)}) or using a {@link org.elasticsearch.common.xcontent.builder.XContentBuilder}
* ({@link #source(org.elasticsearch.common.xcontent.builder.XContentBuilder)}).
* its string form ({@link #source(String)}) or using a {@link org.elasticsearch.common.xcontent.XContentBuilder}
* ({@link #source(org.elasticsearch.common.xcontent.XContentBuilder)}).
*
* <p>If the {@link #id(String)} is not set, it will be automatically generated.
*
Expand Down Expand Up @@ -238,7 +237,7 @@ byte[] source() {
*/
@Required public IndexRequest source(Map source, XContentType contentType) throws ElasticSearchGenerationException {
try {
BinaryXContentBuilder builder = XContentFactory.contentBinaryBuilder(contentType);
XContentBuilder builder = XContentFactory.contentBuilder(contentType);
builder.map(source);
return source(builder);
} catch (IOException e) {
Expand All @@ -249,7 +248,7 @@ byte[] source() {
/**
* Sets the document source to index.
*
* <p>Note, its preferable to either set it using {@link #source(org.elasticsearch.common.xcontent.builder.XContentBuilder)}
* <p>Note, its preferable to either set it using {@link #source(org.elasticsearch.common.xcontent.XContentBuilder)}
* or using the {@link #source(byte[])}.
*/
@Required public IndexRequest source(String source) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@
import org.elasticsearch.common.io.FastByteArrayOutputStream;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.common.xcontent.builder.BinaryXContentBuilder;
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
import org.elasticsearch.search.Scroll;
import org.elasticsearch.search.builder.SearchSourceBuilder;

Expand Down Expand Up @@ -324,7 +323,7 @@ void beforeLocalFork() {
* more like this documents.
*/
public MoreLikeThisRequest searchSource(SearchSourceBuilder sourceBuilder) {
FastByteArrayOutputStream bos = sourceBuilder.buildAsUnsafeBytes();
FastByteArrayOutputStream bos = sourceBuilder.buildAsUnsafeBytes(Requests.CONTENT_TYPE);
this.searchSource = bos.unsafeByteArray();
this.searchSourceOffset = 0;
this.searchSourceLength = bos.size();
Expand All @@ -347,7 +346,7 @@ public MoreLikeThisRequest searchSource(String searchSource) {

public MoreLikeThisRequest searchSource(Map searchSource) {
try {
BinaryXContentBuilder builder = XContentFactory.contentBinaryBuilder(contentType);
XContentBuilder builder = XContentFactory.contentBuilder(contentType);
builder.map(searchSource);
return searchSource(builder);
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.common.xcontent.builder.BinaryXContentBuilder;
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
import org.elasticsearch.search.Scroll;
import org.elasticsearch.search.builder.SearchSourceBuilder;

Expand Down Expand Up @@ -217,7 +216,7 @@ public SearchRequest searchType(String searchType) throws ElasticSearchIllegalAr
* The source of the search request.
*/
public SearchRequest source(SearchSourceBuilder sourceBuilder) {
FastByteArrayOutputStream bos = sourceBuilder.buildAsUnsafeBytes();
FastByteArrayOutputStream bos = sourceBuilder.buildAsUnsafeBytes(Requests.CONTENT_TYPE);
this.source = bos.unsafeByteArray();
this.sourceOffset = 0;
this.sourceLength = bos.size();
Expand All @@ -243,7 +242,7 @@ public SearchRequest source(String source) {
*/
public SearchRequest source(Map source) {
try {
BinaryXContentBuilder builder = XContentFactory.contentBinaryBuilder(contentType);
XContentBuilder builder = XContentFactory.contentBuilder(contentType);
builder.map(source);
return source(builder);
} catch (IOException e) {
Expand Down Expand Up @@ -300,7 +299,7 @@ public int sourceLength() {
* Allows to provide additional source that will be used as well.
*/
public SearchRequest extraSource(SearchSourceBuilder sourceBuilder) {
FastByteArrayOutputStream bos = sourceBuilder.buildAsUnsafeBytes();
FastByteArrayOutputStream bos = sourceBuilder.buildAsUnsafeBytes(Requests.CONTENT_TYPE);
this.extraSource = bos.unsafeByteArray();
this.extraSourceOffset = 0;
this.extraSourceLength = bos.size();
Expand All @@ -310,7 +309,7 @@ public SearchRequest extraSource(SearchSourceBuilder sourceBuilder) {

public SearchRequest extraSource(Map extraSource) {
try {
BinaryXContentBuilder builder = XContentFactory.contentBinaryBuilder(contentType);
XContentBuilder builder = XContentFactory.contentBuilder(contentType);
builder.map(extraSource);
return extraSource(builder);
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.search.SearchHits;
import org.elasticsearch.search.facets.Facets;
import org.elasticsearch.search.internal.InternalSearchResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class Requests {
/**
* The content type used to generate request builders (query / search).
*/
public static XContentType CONTENT_TYPE = XContentType.XSON;
public static XContentType CONTENT_TYPE = XContentType.SMILE;

public static IndexRequest indexRequest() {
return new IndexRequest();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.elasticsearch.client.action.admin.indices.support.BaseIndicesRequestBuilder;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentBuilder;

import java.util.Map;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.elasticsearch.client.IndicesAdminClient;
import org.elasticsearch.client.action.admin.indices.support.BaseIndicesRequestBuilder;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentBuilder;

import java.util.Map;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.elasticsearch.client.Client;
import org.elasticsearch.client.action.support.BaseRequestBuilder;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.index.query.QueryBuilder;

import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import org.elasticsearch.client.Client;
import org.elasticsearch.client.action.support.BaseRequestBuilder;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.common.xcontent.builder.XContentBuilder;

import javax.annotation.Nullable;
import java.util.Map;
Expand Down Expand Up @@ -91,7 +91,7 @@ public IndexRequestBuilder setSource(Map<String, Object> source, XContentType co
/**
* Sets the document source to index.
*
* <p>Note, its preferable to either set it using {@link #setSource(org.elasticsearch.common.xcontent.builder.XContentBuilder)}
* <p>Note, its preferable to either set it using {@link #setSource(org.elasticsearch.common.xcontent.XContentBuilder)}
* or using the {@link #setSource(byte[])}.
*/
public IndexRequestBuilder setSource(String source) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,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.builder.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentBuilder;

import java.io.IOException;
import java.io.Serializable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.Immutable;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.builder.XContentBuilder;

import javax.annotation.Nullable;
import java.io.IOException;
Expand Down
Loading

0 comments on commit 38aeba4

Please sign in to comment.