use of de.spinscale.elasticsearch.action.suggest.refresh.ShardSuggestRefreshResponse in project elasticsearch-suggest-plugin by spinscale.
the class ShardSuggestService method refresh.
public ShardSuggestRefreshResponse refresh(ShardSuggestRefreshRequest shardSuggestRefreshRequest) {
String field = shardSuggestRefreshRequest.field();
if (!Strings.hasLength(field)) {
update();
} else {
resetIndexReader();
HighFrequencyDictionary dict = dictCache.getIfPresent(field);
if (dict != null)
dictCache.refresh(field);
RAMDirectory ramDirectory = ramDirectoryCache.getIfPresent(field);
if (ramDirectory != null) {
ramDirectory.close();
ramDirectoryCache.invalidate(field);
}
SpellChecker spellChecker = spellCheckerCache.getIfPresent(field);
if (spellChecker != null) {
spellCheckerCache.refresh(field);
try {
spellChecker.close();
} catch (IOException e) {
logger.error("Could not close spellchecker in indexshard [{}] for field [{}]", e, indexShard, field);
}
}
FSTCompletionLookup lookup = lookupCache.getIfPresent(field);
if (lookup != null)
lookupCache.refresh(field);
for (FieldType fieldType : analyzingSuggesterCache.asMap().keySet()) {
if (fieldType.field().equals(shardSuggestRefreshRequest.field())) {
analyzingSuggesterCache.refresh(fieldType);
}
}
for (FieldType fieldType : fuzzySuggesterCache.asMap().keySet()) {
if (fieldType.field().equals(shardSuggestRefreshRequest.field())) {
fuzzySuggesterCache.refresh(fieldType);
}
}
}
return new ShardSuggestRefreshResponse(shardId.index().name(), shardId.id());
}
Aggregations