diff options
Diffstat (limited to 'core/src/main/java/org/elasticsearch/action/bulk/byscroll')
-rw-r--r-- | core/src/main/java/org/elasticsearch/action/bulk/byscroll/ClientScrollableHitSource.java | 6 | ||||
-rw-r--r-- | core/src/main/java/org/elasticsearch/action/bulk/byscroll/ScrollableHitSource.java | 16 |
2 files changed, 20 insertions, 2 deletions
diff --git a/core/src/main/java/org/elasticsearch/action/bulk/byscroll/ClientScrollableHitSource.java b/core/src/main/java/org/elasticsearch/action/bulk/byscroll/ClientScrollableHitSource.java index 8831b2f636..4f2aefc101 100644 --- a/core/src/main/java/org/elasticsearch/action/bulk/byscroll/ClientScrollableHitSource.java +++ b/core/src/main/java/org/elasticsearch/action/bulk/byscroll/ClientScrollableHitSource.java @@ -37,6 +37,8 @@ import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.util.concurrent.AbstractRunnable; import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; +import org.elasticsearch.common.xcontent.XContentFactory; +import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.index.mapper.ParentFieldMapper; import org.elasticsearch.index.mapper.RoutingFieldMapper; import org.elasticsearch.search.SearchHit; @@ -233,6 +235,10 @@ public class ClientScrollableHitSource extends ScrollableHitSource { } @Override + public XContentType getXContentType() { + return XContentFactory.xContentType(source); + } + @Override public long getVersion() { return delegate.getVersion(); } diff --git a/core/src/main/java/org/elasticsearch/action/bulk/byscroll/ScrollableHitSource.java b/core/src/main/java/org/elasticsearch/action/bulk/byscroll/ScrollableHitSource.java index 8b8a350ffd..73aa653698 100644 --- a/core/src/main/java/org/elasticsearch/action/bulk/byscroll/ScrollableHitSource.java +++ b/core/src/main/java/org/elasticsearch/action/bulk/byscroll/ScrollableHitSource.java @@ -32,6 +32,7 @@ import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.search.SearchHit; import org.elasticsearch.threadpool.ThreadPool; @@ -80,7 +81,7 @@ public abstract class ScrollableHitSource implements Closeable { }); } protected abstract void doStartNextScroll(String scrollId, TimeValue extraKeepAlive, Consumer<? super Response> onResponse); - + @Override public final void close() { String scrollId = this.scrollId.get(); @@ -190,6 +191,10 @@ public abstract class ScrollableHitSource implements Closeable { */ @Nullable BytesReference getSource(); /** + * The content type of the hit source. Returns null if the source didn't come back from the search. + */ + @Nullable XContentType getXContentType(); + /** * The document id of the parent of the hit if there is a parent or null if there isn't. */ @Nullable String getParent(); @@ -209,6 +214,7 @@ public abstract class ScrollableHitSource implements Closeable { private final long version; private BytesReference source; + private XContentType xContentType; private String parent; private String routing; @@ -244,8 +250,14 @@ public abstract class ScrollableHitSource implements Closeable { return source; } - public BasicHit setSource(BytesReference source) { + @Override + public XContentType getXContentType() { + return xContentType; + } + + public BasicHit setSource(BytesReference source, XContentType xContentType) { this.source = source; + this.xContentType = xContentType; return this; } |