use of org.elasticsearch.index.service.IndexService in project elasticsearch-suggest-plugin by spinscale.
the class TransportSuggestRefreshAction method shardOperation.
@Override
protected ShardSuggestRefreshResponse shardOperation(ShardSuggestRefreshRequest request) throws ElasticsearchException {
logger.trace("Entered TransportSuggestRefreshAction.shardOperation()");
IndexService indexService = indicesService.indexServiceSafe(request.index());
ShardSuggestService suggestShardService = indexService.shardInjectorSafe(request.shardId()).getInstance(ShardSuggestService.class);
return suggestShardService.refresh(request);
}
use of org.elasticsearch.index.service.IndexService in project elasticsearch-skywalker by jprante.
the class TransportReconstructAction method shardOperation.
@Override
protected ShardReconstructIndexResponse shardOperation(ShardReconstructIndexRequest request) throws ElasticsearchException {
IndexService indexService = indicesService.indexService(request.index());
InternalIndexShard indexShard = (InternalIndexShard) indexService.shardSafe(request.shardId());
Engine.Searcher searcher = indexShard.engine().acquireSearcher("transport_reconstruct");
IndexReader reader = searcher.reader();
DocumentReconstructor dr = new DocumentReconstructor(reader);
try {
return new ShardReconstructIndexResponse(true, dr.reconstruct(request.shardId()));
} catch (IOException e) {
throw new ElasticsearchException("failed to reconstruct index", e);
}
}
use of org.elasticsearch.index.service.IndexService in project elasticsearch-skywalker by jprante.
the class TransportSkywalkerAction method shardOperation.
@Override
protected ShardSkywalkerResponse shardOperation(ShardSkywalkerRequest request) throws ElasticsearchException {
synchronized (mutex) {
IndexService indexService = indicesService.indexServiceSafe(request.index());
InternalIndexShard indexShard = (InternalIndexShard) indexService.shardSafe(request.shardId());
MapperService mapperService = indexService.mapperService();
Engine.Searcher searcher = indexShard.acquireSearcher("skywalker_action");
try {
IndexReader reader = searcher.reader();
Skywalker skywalker = new Skywalker(reader);
Map<String, Object> response = new HashMap();
Directory directory = indexShard.store().directory();
List indexFiles = new ArrayList();
for (String f : skywalker.getIndexFiles(directory)) {
Map indexFile = new HashMap();
indexFile.put("name", f);
indexFile.put("function", skywalker.getFileFunction(f));
indexFiles.add(indexFile);
}
response.put("indexFiles", indexFiles);
skywalker.getStoreMetadata(response, indexShard.store().getMetadata());
response.put("indexVersion", skywalker.getVersion());
response.put("directoryImpl", skywalker.getDirImpl());
response.put("numDocs", reader.numDocs());
response.put("maxDoc", reader.maxDoc());
response.put("hasDeletions", reader.hasDeletions());
response.put("numDeletedDocs", reader.numDeletedDocs());
Set<FieldTermCount> ftc = skywalker.getFieldTermCounts();
response.put("numTerms", skywalker.getNumTerms());
Map indexFormatInfo = new HashMap();
FormatDetails details = skywalker.getFormatDetails();
indexFormatInfo.put("version", details.getVersion());
indexFormatInfo.put("genericName", details.getGenericName());
indexFormatInfo.put("capabilities", details.getCapabilities());
response.put("indexFormat", indexFormatInfo);
List commits = new ArrayList();
Iterator<Segment> it = indexShard.engine().segments().iterator();
while (it.hasNext()) {
Segment segment = it.next();
Map m = new HashMap();
m.put("segment", segment.getName());
m.put("count", segment.getNumDocs());
m.put("deleted", segment.getDeletedDocs());
m.put("generation", segment.getGeneration());
m.put("sizeInBytes", segment.getSizeInBytes());
m.put("version", segment.getVersion());
m.put("committed", segment.committed);
m.put("compound", segment.compound);
m.put("size", segment.getSize().toString());
commits.add(m);
}
response.put("commits", commits);
List fieldInfos = new ArrayList();
for (FieldInfo fi : MultiFields.getMergedFieldInfos(reader)) {
fieldInfos.add(skywalker.getFieldInfo(mapperService, fi));
}
response.put("fieldInfos", fieldInfos);
List termList = new ArrayList();
for (TermStats ts : skywalker.getTopTerms(50)) {
Map m = new HashMap();
m.put("field", ts.field());
m.put("text", ts.text());
m.put("docFreq", ts.docFreq());
termList.add(m);
}
response.put("topterms", termList);
return new ShardSkywalkerResponse(request.index(), request.shardId()).setResponse(response);
} catch (Exception ex) {
throw new ElasticsearchException(ex.getMessage(), ex);
}
}
}
use of org.elasticsearch.index.service.IndexService in project elasticsearch-suggest-plugin by spinscale.
the class TransportSuggestStatisticsAction method shardOperation.
@Override
protected ShardSuggestStatisticsResponse shardOperation(ShardSuggestStatisticsRequest request) throws ElasticsearchException {
IndexService indexService = indicesService.indexServiceSafe(request.index());
ShardSuggestService suggestShardService = indexService.shardInjectorSafe(request.shardId()).getInstance(ShardSuggestService.class);
return suggestShardService.getStatistics();
}
use of org.elasticsearch.index.service.IndexService in project elasticsearch-suggest-plugin by spinscale.
the class TransportSuggestAction method shardOperation.
@Override
protected ShardSuggestResponse shardOperation(ShardSuggestRequest request) throws ElasticsearchException {
logger.trace("Entered TransportSuggestAction.shardOperation()");
IndexService indexService = indicesService.indexServiceSafe(request.index());
ShardSuggestService suggestShardService = indexService.shardInjectorSafe(request.shardId()).getInstance(ShardSuggestService.class);
return suggestShardService.suggest(request);
}
Aggregations