本文整理了Java中org.elasticsearch.search.builder.SearchSourceBuilder.fetchSource()
方法的一些代码示例,展示了SearchSourceBuilder.fetchSource()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SearchSourceBuilder.fetchSource()
方法的具体详情如下:
包路径:org.elasticsearch.search.builder.SearchSourceBuilder
类名称:SearchSourceBuilder
方法名:fetchSource
[英]Gets the FetchSourceContext which defines how the _source should be fetched.
[中]获取FetchSourceContext,该上下文定义如何获取_源。
代码示例来源:origin: floragunncom/search-guard
public SourceFieldsContext(SearchRequest request) {
if (request.source() != null && request.source().fetchSource() != null) {
includes = request.source().fetchSource().includes();
excludes = request.source().fetchSource().excludes();
fetchSource = request.source().fetchSource().fetchSource();
}
//if (request.source() != null && request.source().storedFields() != null && request.source().storedFields().fieldNames() != null) {
// storedFields = request.source().storedFields().fieldNames().toArray(new String[0]);
//}
}
代码示例来源:origin: floragunncom/search-guard
public static boolean isNeeded(SearchRequest request) {
return (request.source() != null && request.source().fetchSource() != null && (request.source().fetchSource().includes() != null || request
.source().fetchSource().excludes() != null))
|| (request.source() != null && request.source().storedFields() != null
&& request.source().storedFields().fieldNames() != null && !request.source().storedFields().fieldNames().isEmpty());
}
代码示例来源:origin: Graylog2/graylog2-server
private SearchSourceBuilder searchRequest(SearchesConfig config) {
final SearchSourceBuilder request;
if (config.filter() == null) {
request = standardSearchRequest(config.query(), config.limit(), config.offset(), config.range(), config.sorting());
} else {
request = filteredSearchRequest(config.query(), config.filter(), config.limit(), config.offset(), config.range(), config.sorting());
}
final List<String> fields = config.fields();
if (fields != null) {
// Use source filtering instead of SearchSourceBuilder#fields() here because Jest cannot handle responses
// without a "_source" field yet. See:
// https://github.com/searchbox-io/Jest/issues/157
// https://github.com/searchbox-io/Jest/issues/339
request.fetchSource(fields.toArray(new String[fields.size()]), Strings.EMPTY_ARRAY);
}
return request;
}
代码示例来源:origin: spring-projects/spring-data-elasticsearch
private SearchRequest prepareScroll(Query query, long scrollTimeInMillis) {
SearchRequest request = new SearchRequest(toArray(query.getIndices()));
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
request.types(toArray(query.getTypes()));
request.scroll(TimeValue.timeValueMillis(scrollTimeInMillis));
if (query.getPageable().isPaged()) {
searchSourceBuilder.size(query.getPageable().getPageSize());
}
if (!isEmpty(query.getFields())) {
searchSourceBuilder.fetchSource(toArray(query.getFields()), null);
}
request.source(searchSourceBuilder);
return request;
}
代码示例来源:origin: spring-projects/spring-data-elasticsearch
sourceBuilder.fetchSource(sourceFilter.getIncludes(), sourceFilter.getExcludes());
sourceBuilder.fetchSource(toArray(query.getFields()), null);
代码示例来源:origin: spring-projects/spring-data-elasticsearch
searchSourceBuilder.fetchSource(query.getSourceFilter().getIncludes(), query.getSourceFilter().getExcludes());
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* Indicates whether the response should contain the stored _source for every hit
*/
public SearchRequestBuilder setFetchSource(boolean fetch) {
sourceBuilder().fetchSource(fetch);
return this;
}
代码示例来源:origin: org.elasticsearch/elasticsearch
private DeleteByQueryRequest(SearchRequest search, boolean setDefaults) {
super(search, setDefaults);
// Delete-By-Query does not require the source
if (setDefaults) {
search.source().fetchSource(false);
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* Indicate that _source should be returned with every hit, with an
* "include" and/or "exclude" set which can include simple wildcard
* elements.
*
* @param include
* An optional include (optionally wildcarded) pattern to filter
* the returned _source
* @param exclude
* An optional exclude (optionally wildcarded) pattern to filter
* the returned _source
*/
public SearchSourceBuilder fetchSource(@Nullable String include, @Nullable String exclude) {
return fetchSource(include == null ? Strings.EMPTY_ARRAY : new String[] { include }, exclude == null ? Strings.EMPTY_ARRAY
: new String[] { exclude });
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* Indicate that _source should be returned with every hit, with an "include" and/or "exclude" set which can include simple wildcard
* elements.
*
* @param includes An optional list of include (optionally wildcarded) pattern to filter the returned _source
* @param excludes An optional list of exclude (optionally wildcarded) pattern to filter the returned _source
*/
public SearchRequestBuilder setFetchSource(@Nullable String[] includes, @Nullable String[] excludes) {
sourceBuilder().fetchSource(includes, excludes);
return this;
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* Indicate that _source should be returned with every hit, with an "include" and/or "exclude" set which can include simple wildcard
* elements.
*
* @param include An optional include (optionally wildcarded) pattern to filter the returned _source
* @param exclude An optional exclude (optionally wildcarded) pattern to filter the returned _source
*/
public SearchRequestBuilder setFetchSource(@Nullable String include, @Nullable String exclude) {
sourceBuilder().fetchSource(include, exclude);
return this;
}
代码示例来源:origin: apache/servicemix-bundles
private DeleteByQueryRequest(SearchRequest search, boolean setDefaults) {
super(search, setDefaults);
// Delete-By-Query does not require the source
if (setDefaults) {
search.source().fetchSource(false);
}
}
代码示例来源:origin: apache/metron
builder.query(qb);
builder.size(pageSize);
builder.fetchSource(true);
builder.storedField("*");
request.source(builder);
代码示例来源:origin: apache/metron
searchBuilder.fetchSource("*", null);
} else {
searchBuilder.fetchSource(true);
代码示例来源:origin: org.elasticsearch/elasticsearch
groupSource.fetchSource(options.getFetchSourceContext().fetchSource());
} else {
groupSource.fetchSource(options.getFetchSourceContext().includes(),
options.getFetchSourceContext().excludes());
代码示例来源:origin: org.elasticsearch/elasticsearch
e = addValidationError("use _all if you really want to copy from all existing indexes", e);
if (getSearchRequest().source().fetchSource() != null && getSearchRequest().source().fetchSource().fetchSource() == false) {
e = addValidationError("_source:false is not supported in this context", e);
代码示例来源:origin: org.elasticsearch/elasticsearch
searchSourceBuilder.fetchSource(fetchSourceContext);
代码示例来源:origin: com.floragunn/search-guard-6
public SourceFieldsContext(SearchRequest request) {
if (request.source() != null && request.source().fetchSource() != null) {
includes = request.source().fetchSource().includes();
excludes = request.source().fetchSource().excludes();
fetchSource = request.source().fetchSource().fetchSource();
}
//if (request.source() != null && request.source().storedFields() != null && request.source().storedFields().fieldNames() != null) {
// storedFields = request.source().storedFields().fieldNames().toArray(new String[0]);
//}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
context.explain(source.explain());
if (source.fetchSource() != null) {
context.fetchSourceContext(source.fetchSource());
代码示例来源:origin: com.floragunn/search-guard-6
public static boolean isNeeded(SearchRequest request) {
return (request.source() != null && request.source().fetchSource() != null && (request.source().fetchSource().includes() != null || request
.source().fetchSource().excludes() != null))
|| (request.source() != null && request.source().storedFields() != null
&& request.source().storedFields().fieldNames() != null && !request.source().storedFields().fieldNames().isEmpty());
}
内容来源于网络,如有侵权,请联系作者删除!