add the ability to set source and extra source on the SearchRequestBuilder
This commit is contained in:
parent
80a797fc4f
commit
0df3dfd72b
|
@ -294,6 +294,14 @@ public class SearchRequest implements ActionRequest {
|
|||
return source(source, 0, source.length, false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The search source to execute.
|
||||
*/
|
||||
public SearchRequest source(byte[] source, int offset, int length) {
|
||||
return source(source, offset, length, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* The search source to execute.
|
||||
*/
|
||||
|
@ -373,6 +381,13 @@ public class SearchRequest implements ActionRequest {
|
|||
return extraSource(source, 0, source.length, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows to provide additional source that will be used as well.
|
||||
*/
|
||||
public SearchRequest extraSource(byte[] source, int offset, int length) {
|
||||
return extraSource(source, offset, length, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows to provide additional source that will be used as well.
|
||||
*/
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.elasticsearch.action.search.SearchType;
|
|||
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.index.query.xcontent.XContentFilterBuilder;
|
||||
import org.elasticsearch.index.query.xcontent.XContentQueryBuilder;
|
||||
import org.elasticsearch.search.Scroll;
|
||||
|
@ -474,6 +475,78 @@ public class SearchRequestBuilder extends BaseRequestBuilder<SearchRequest, Sear
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the source of the request as a json string. Note, settings anything other
|
||||
* than the search type will cause this source to be overridden, consifer using
|
||||
* {@link #setExtraSource(String)}.
|
||||
*/
|
||||
public SearchRequestBuilder setSource(String source) {
|
||||
request.source(source);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the source of the request as a json string. Allows to set other parameters.
|
||||
*/
|
||||
public SearchRequestBuilder setExtraSource(String source) {
|
||||
request.extraSource(source);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the source of the request as a json string. Note, settings anything other
|
||||
* than the search type will cause this source to be overridden, consifer using
|
||||
* {@link #setExtraSource(byte[])}.
|
||||
*/
|
||||
public SearchRequestBuilder setSource(byte[] source) {
|
||||
request.source(source);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the source of the request as a json string. Allows to set other parameters.
|
||||
*/
|
||||
public SearchRequestBuilder setExtraSource(byte[] source) {
|
||||
request.extraSource(source);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the source of the request as a json string. Note, settings anything other
|
||||
* than the search type will cause this source to be overridden, consifer using
|
||||
* {@link #setExtraSource(byte[])}.
|
||||
*/
|
||||
public SearchRequestBuilder setSource(byte[] source, int offset, int length) {
|
||||
request.source(source, offset, length);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the source of the request as a json string. Allows to set other parameters.
|
||||
*/
|
||||
public SearchRequestBuilder setExtraSource(byte[] source, int offset, int length) {
|
||||
request.extraSource(source, offset, length);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the source of the request as a json string. Note, settings anything other
|
||||
* than the search type will cause this source to be overridden, consifer using
|
||||
* {@link #setExtraSource(byte[])}.
|
||||
*/
|
||||
public SearchRequestBuilder setSource(XContentBuilder builder) {
|
||||
request.source(builder);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the source of the request as a json string. Allows to set other parameters.
|
||||
*/
|
||||
public SearchRequestBuilder setExtraSource(XContentBuilder builder) {
|
||||
request.extraSource(builder);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the source builder to be used with this request. Note, any operations done
|
||||
* on this require builder before are discarded as this internal builder replaces
|
||||
|
|
Loading…
Reference in New Issue