本文整理汇总了Java中org.elasticsearch.search.fetch.FetchSubPhase类的典型用法代码示例。如果您正苦于以下问题:Java FetchSubPhase类的具体用法?Java FetchSubPhase怎么用?Java FetchSubPhase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FetchSubPhase类属于org.elasticsearch.search.fetch包,在下文中一共展示了FetchSubPhase类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: loadFieldValues
import org.elasticsearch.search.fetch.FetchSubPhase; //导入依赖的package包/类
/**
* Load field values for highlighting.
*/
public static List<Object> loadFieldValues(SearchContextHighlight.Field field, FieldMapper mapper, SearchContext searchContext,
FetchSubPhase.HitContext hitContext) throws IOException {
//percolator needs to always load from source, thus it sets the global force source to true
boolean forceSource = searchContext.highlight().forceSource(field);
List<Object> textsToHighlight;
if (!forceSource && mapper.fieldType().stored()) {
CustomFieldsVisitor fieldVisitor = new CustomFieldsVisitor(singleton(mapper.fieldType().name()), false);
hitContext.reader().document(hitContext.docId(), fieldVisitor);
textsToHighlight = fieldVisitor.fields().get(mapper.fieldType().name());
if (textsToHighlight == null) {
// Can happen if the document doesn't have the field to highlight
textsToHighlight = Collections.emptyList();
}
} else {
SourceLookup sourceLookup = searchContext.lookup().source();
sourceLookup.setSegmentAndDocument(hitContext.readerContext(), hitContext.docId());
textsToHighlight = sourceLookup.extractRawValues(mapper.fieldType().name());
}
assert textsToHighlight != null;
return textsToHighlight;
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:HighlightUtils.java
示例2: testBasicFiltering
import org.elasticsearch.search.fetch.FetchSubPhase; //导入依赖的package包/类
public void testBasicFiltering() throws IOException {
XContentBuilder source = XContentFactory.jsonBuilder().startObject()
.field("field1", "value")
.field("field2", "value2")
.endObject();
FetchSubPhase.HitContext hitContext = hitExecute(source, false, null, null);
assertNull(hitContext.hit().getSourceAsMap());
hitContext = hitExecute(source, true, "field1", null);
assertEquals(Collections.singletonMap("field1","value"), hitContext.hit().getSourceAsMap());
hitContext = hitExecute(source, true, "hello", null);
assertEquals(Collections.emptyMap(), hitContext.hit().getSourceAsMap());
hitContext = hitExecute(source, true, "*", "field2");
assertEquals(Collections.singletonMap("field1","value"), hitContext.hit().getSourceAsMap());
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:FetchSourceSubPhaseTests.java
示例3: testSourceDisabled
import org.elasticsearch.search.fetch.FetchSubPhase; //导入依赖的package包/类
public void testSourceDisabled() throws IOException {
FetchSubPhase.HitContext hitContext = hitExecute(null, true, null, null);
assertNull(hitContext.hit().getSourceAsMap());
hitContext = hitExecute(null, false, null, null);
assertNull(hitContext.hit().getSourceAsMap());
IllegalArgumentException exception = expectThrows(IllegalArgumentException.class, () -> hitExecute(null, true, "field1", null));
assertEquals("unable to fetch fields from _source field: _source is disabled in the mappings " +
"for index [index]", exception.getMessage());
exception = expectThrows(IllegalArgumentException.class,
() -> hitExecuteMultiple(null, true, new String[]{"*"}, new String[]{"field2"}));
assertEquals("unable to fetch fields from _source field: _source is disabled in the mappings " +
"for index [index]", exception.getMessage());
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:FetchSourceSubPhaseTests.java
示例4: loadFieldValues
import org.elasticsearch.search.fetch.FetchSubPhase; //导入依赖的package包/类
static List<Object> loadFieldValues(SearchContextHighlight.Field field, FieldMapper mapper, SearchContext searchContext, FetchSubPhase.HitContext hitContext) throws IOException {
//percolator needs to always load from source, thus it sets the global force source to true
boolean forceSource = searchContext.highlight().forceSource(field);
List<Object> textsToHighlight;
if (!forceSource && mapper.fieldType().stored()) {
CustomFieldsVisitor fieldVisitor = new CustomFieldsVisitor(ImmutableSet.of(mapper.fieldType().names().indexName()), false);
hitContext.reader().document(hitContext.docId(), fieldVisitor);
textsToHighlight = fieldVisitor.fields().get(mapper.fieldType().names().indexName());
if (textsToHighlight == null) {
// Can happen if the document doesn't have the field to highlight
textsToHighlight = Collections.emptyList();
}
} else {
SourceLookup sourceLookup = searchContext.lookup().source();
sourceLookup.setSegmentAndDocument(hitContext.readerContext(), hitContext.docId());
textsToHighlight = sourceLookup.extractRawValues(hitContext.getSourcePath(mapper.fieldType().names().fullName()));
}
assert textsToHighlight != null;
return textsToHighlight;
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:21,代码来源:HighlightUtils.java
示例5: topDocs
import org.elasticsearch.search.fetch.FetchSubPhase; //导入依赖的package包/类
@Override
public TopDocs topDocs(SearchContext context, FetchSubPhase.HitContext hitContext) throws IOException {
Query rawParentFilter;
if (parentObjectMapper == null) {
rawParentFilter = Queries.newNonNestedFilter();
} else {
rawParentFilter = parentObjectMapper.nestedTypeFilter();
}
BitSetProducer parentFilter = context.bitsetFilterCache().getBitSetProducer(rawParentFilter);
Query childFilter = childObjectMapper.nestedTypeFilter();
Query q = Queries.filtered(query(), new NestedChildrenQuery(parentFilter, childFilter, hitContext));
if (size() == 0) {
return new TopDocs(context.searcher().count(q), Lucene.EMPTY_SCORE_DOCS, 0);
} else {
int topN = Math.min(from() + size(), context.searcher().getIndexReader().maxDoc());
TopDocsCollector topDocsCollector;
if (sort() != null) {
try {
topDocsCollector = TopFieldCollector.create(sort().sort, topN, true, trackScores(), trackScores());
} catch (IOException e) {
throw ExceptionsHelper.convertToElastic(e);
}
} else {
topDocsCollector = TopScoreDocCollector.create(topN);
}
try {
context.searcher().search(q, topDocsCollector);
} finally {
clearReleasables(Lifetime.COLLECTION);
}
return topDocsCollector.topDocs(from(), size());
}
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:35,代码来源:InnerHitsContext.java
示例6: HighlighterContext
import org.elasticsearch.search.fetch.FetchSubPhase; //导入依赖的package包/类
public HighlighterContext(String fieldName, SearchContextHighlight.Field field, FieldMapper mapper, SearchContext context,
FetchSubPhase.HitContext hitContext, Query query) {
this.fieldName = fieldName;
this.field = field;
this.mapper = mapper;
this.context = context;
this.hitContext = hitContext;
this.query = query;
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:HighlighterContext.java
示例7: registerFetchSubPhase
import org.elasticsearch.search.fetch.FetchSubPhase; //导入依赖的package包/类
private void registerFetchSubPhase(FetchSubPhase subPhase) {
Class<?> subPhaseClass = subPhase.getClass();
if (fetchSubPhases.stream().anyMatch(p -> p.getClass().equals(subPhaseClass))) {
throw new IllegalArgumentException("FetchSubPhase [" + subPhaseClass + "] already registered");
}
fetchSubPhases.add(requireNonNull(subPhase, "FetchSubPhase must not be null"));
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:SearchModule.java
示例8: testFetchSource
import org.elasticsearch.search.fetch.FetchSubPhase; //导入依赖的package包/类
public void testFetchSource() throws IOException {
XContentBuilder source = XContentFactory.jsonBuilder().startObject()
.field("field", "value")
.endObject();
FetchSubPhase.HitContext hitContext = hitExecute(source, true, null, null);
assertEquals(Collections.singletonMap("field","value"), hitContext.hit().getSourceAsMap());
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:FetchSourceSubPhaseTests.java
示例9: testMultipleFiltering
import org.elasticsearch.search.fetch.FetchSubPhase; //导入依赖的package包/类
public void testMultipleFiltering() throws IOException {
XContentBuilder source = XContentFactory.jsonBuilder().startObject()
.field("field", "value")
.field("field2", "value2")
.endObject();
FetchSubPhase.HitContext hitContext = hitExecuteMultiple(source, true, new String[]{"*.notexisting", "field"}, null);
assertEquals(Collections.singletonMap("field","value"), hitContext.hit().getSourceAsMap());
hitContext = hitExecuteMultiple(source, true, new String[]{"field.notexisting.*", "field"}, null);
assertEquals(Collections.singletonMap("field","value"), hitContext.hit().getSourceAsMap());
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:FetchSourceSubPhaseTests.java
示例10: hitExecuteMultiple
import org.elasticsearch.search.fetch.FetchSubPhase; //导入依赖的package包/类
private FetchSubPhase.HitContext hitExecuteMultiple(XContentBuilder source, boolean fetchSource, String[] includes, String[] excludes) {
FetchSourceContext fetchSourceContext = new FetchSourceContext(fetchSource, includes, excludes);
SearchContext searchContext = new FetchSourceSubPhaseTestSearchContext(fetchSourceContext, source == null ? null : source.bytes());
FetchSubPhase.HitContext hitContext = new FetchSubPhase.HitContext();
hitContext.reset(new SearchHit(1, null, null, null), null, 1, null);
FetchSourceSubPhase phase = new FetchSourceSubPhase();
phase.hitExecute(searchContext, hitContext);
return hitContext;
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:FetchSourceSubPhaseTests.java
示例11: getFetchSubPhaseContext
import org.elasticsearch.search.fetch.FetchSubPhase; //导入依赖的package包/类
@Override
public <SubPhaseContext extends FetchSubPhaseContext> SubPhaseContext getFetchSubPhaseContext(FetchSubPhase.ContextFactory<SubPhaseContext> contextFactory) {
String subPhaseName = contextFactory.getName();
if (subPhaseContexts.get(subPhaseName) == null) {
subPhaseContexts.put(subPhaseName, contextFactory.newContextInstance());
}
return (SubPhaseContext) subPhaseContexts.get(subPhaseName);
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:9,代码来源:PercolateContext.java
示例12: topDocs
import org.elasticsearch.search.fetch.FetchSubPhase; //导入依赖的package包/类
@Override
public TopDocs topDocs(SearchContext context, FetchSubPhase.HitContext hitContext) throws IOException {
Query rawParentFilter;
if (parentObjectMapper == null) {
rawParentFilter = Queries.newNonNestedFilter();
} else {
rawParentFilter = parentObjectMapper.nestedTypeFilter();
}
BitSetProducer parentFilter = context.bitsetFilterCache().getBitSetProducer(rawParentFilter);
Query childFilter = childObjectMapper.nestedTypeFilter();
Query q = Queries.filtered(query.query(), new NestedChildrenQuery(parentFilter, childFilter, hitContext));
if (size() == 0) {
return new TopDocs(context.searcher().count(q), Lucene.EMPTY_SCORE_DOCS, 0);
} else {
int topN = Math.min(from() + size(), context.searcher().getIndexReader().maxDoc());
TopDocsCollector topDocsCollector;
if (sort() != null) {
try {
topDocsCollector = TopFieldCollector.create(sort(), topN, true, trackScores(), trackScores());
} catch (IOException e) {
throw ExceptionsHelper.convertToElastic(e);
}
} else {
topDocsCollector = TopScoreDocCollector.create(topN);
}
try {
context.searcher().search(q, topDocsCollector);
} finally {
clearReleasables(Lifetime.COLLECTION);
}
return topDocsCollector.topDocs(from(), size());
}
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:35,代码来源:InnerHitsContext.java
示例13: configureFetchSubPhase
import org.elasticsearch.search.fetch.FetchSubPhase; //导入依赖的package包/类
protected void configureFetchSubPhase() {
Multibinder<FetchSubPhase> fetchSubPhaseMultibinder = Multibinder.newSetBinder(binder(), FetchSubPhase.class);
fetchSubPhaseMultibinder.addBinding().to(ExplainFetchSubPhase.class);
fetchSubPhaseMultibinder.addBinding().to(FieldDataFieldsFetchSubPhase.class);
fetchSubPhaseMultibinder.addBinding().to(ScriptFieldsFetchSubPhase.class);
fetchSubPhaseMultibinder.addBinding().to(FetchSourceSubPhase.class);
fetchSubPhaseMultibinder.addBinding().to(VersionFetchSubPhase.class);
fetchSubPhaseMultibinder.addBinding().to(MatchedQueriesFetchSubPhase.class);
fetchSubPhaseMultibinder.addBinding().to(HighlightPhase.class);
for (Class<? extends FetchSubPhase> clazz : fetchSubPhases) {
fetchSubPhaseMultibinder.addBinding().to(clazz);
}
bind(InnerHitsFetchSubPhase.class).asEagerSingleton();
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:15,代码来源:SearchModule.java
示例14: SourceScoreOrderFragmentsBuilder
import org.elasticsearch.search.fetch.FetchSubPhase; //导入依赖的package包/类
public SourceScoreOrderFragmentsBuilder(FieldMapper mapper, SearchContext searchContext,
FetchSubPhase.HitContext hitContext, String[] preTags, String[] postTags, BoundaryScanner boundaryScanner) {
super(preTags, postTags, boundaryScanner);
this.mapper = mapper;
this.searchContext = searchContext;
this.hitContext = hitContext;
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:8,代码来源:SourceScoreOrderFragmentsBuilder.java
示例15: getFetchSubPhases
import org.elasticsearch.search.fetch.FetchSubPhase; //导入依赖的package包/类
@Override
public List<FetchSubPhase> getFetchSubPhases(FetchPhaseConstructionContext context) {
return Arrays.asList(
new TermVectorsFetchSubPhase(),
new AnalyzedTextFetchSubPhase()
);
}
开发者ID:brwe,项目名称:es-token-plugin,代码行数:8,代码来源:TokenPlugin.java
示例16: BulkWriterCollector
import org.elasticsearch.search.fetch.FetchSubPhase; //导入依赖的package包/类
@Inject
public BulkWriterCollector(@Assisted SearchIntoContext context,
Client client, ScriptFieldsFetchSubPhase scriptFieldsPhase,
VersionFetchSubPhase versionFetchSubPhase) {
super(context,
new FetchSubPhase[]{versionFetchSubPhase, scriptFieldsPhase});
this.client = client;
}
开发者ID:crate,项目名称:elasticsearch-inout-plugin,代码行数:9,代码来源:BulkWriterCollector.java
示例17: Exporter
import org.elasticsearch.search.fetch.FetchSubPhase; //导入依赖的package包/类
@Inject
public Exporter(VersionFetchSubPhase versionPhase, Injector injector,
SettingsFilter settingsFilter) {
this.fetchSubPhases = new FetchSubPhase[]{versionPhase};
this.injector = injector;
this.settingsFilter = settingsFilter;
}
开发者ID:crate,项目名称:elasticsearch-inout-plugin,代码行数:8,代码来源:Exporter.java
示例18: getFetchSubPhases
import org.elasticsearch.search.fetch.FetchSubPhase; //导入依赖的package包/类
@Override
public List<FetchSubPhase> getFetchSubPhases(FetchPhaseConstructionContext context) {
return singletonList(new PercolatorHighlightSubFetchPhase(settings, context.getHighlighters()));
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:PercolatorPlugin.java
示例19: NestedChildrenQuery
import org.elasticsearch.search.fetch.FetchSubPhase; //导入依赖的package包/类
NestedChildrenQuery(BitSetProducer parentFilter, Query childFilter, FetchSubPhase.HitContext hitContext) {
this.parentFilter = parentFilter;
this.childFilter = childFilter;
this.docId = hitContext.docId();
this.leafReader = hitContext.readerContext().reader();
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:7,代码来源:InnerHitsContext.java
示例20: getFetchSubPhases
import org.elasticsearch.search.fetch.FetchSubPhase; //导入依赖的package包/类
/**
* The new {@link FetchSubPhase}s defined by this plugin.
*/
default List<FetchSubPhase> getFetchSubPhases(FetchPhaseConstructionContext context) {
return emptyList();
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:7,代码来源:SearchPlugin.java
注:本文中的org.elasticsearch.search.fetch.FetchSubPhase类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论