Java Code Examples for org.elasticsearch.index.shard.IndexShard#refresh()
The following examples show how to use
org.elasticsearch.index.shard.IndexShard#refresh() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PercolatorQueriesRegistry.java From Elasticsearch with Apache License 2.0 | 6 votes |
private int loadQueries(IndexShard shard) { shard.refresh("percolator_load_queries"); // NOTE: we acquire the searcher via the engine directly here since this is executed right // before the shard is marked as POST_RECOVERY try (Engine.Searcher searcher = shard.engine().acquireSearcher("percolator_load_queries")) { Query query = new TermQuery(new Term(TypeFieldMapper.NAME, PercolatorService.TYPE_NAME)); QueriesLoaderCollector queryCollector = new QueriesLoaderCollector(PercolatorQueriesRegistry.this, logger, mapperService, indexFieldDataService); IndexSearcher indexSearcher = new IndexSearcher(searcher.reader()); indexSearcher.setQueryCache(null); indexSearcher.search(query, queryCollector); Map<BytesRef, Query> queries = queryCollector.queries(); for (Map.Entry<BytesRef, Query> entry : queries.entrySet()) { Query previousQuery = percolateQueries.put(entry.getKey(), entry.getValue()); shardPercolateService.addedQuery(entry.getKey(), previousQuery, entry.getValue()); } return queries.size(); } catch (Exception e) { throw new PercolatorException(shardId.index(), "failed to load queries from percolator index", e); } }
Example 2
Source File: TransportShardRefreshAction.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override protected Tuple<ActionWriteResponse, ReplicationRequest> shardOperationOnPrimary(MetaData metaData, ReplicationRequest shardRequest) throws Throwable { IndexShard indexShard = indicesService.indexServiceSafe(shardRequest.shardId().getIndex()).shardSafe(shardRequest.shardId().id()); indexShard.refresh("api"); logger.trace("{} refresh request executed on primary", indexShard.shardId()); return new Tuple<>(new ActionWriteResponse(), shardRequest); }
Example 3
Source File: TransportShardMultiGetAction.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override protected MultiGetShardResponse shardOperation(MultiGetShardRequest request, ShardId shardId) { IndexService indexService = indicesService.indexServiceSafe(shardId.getIndex()); IndexShard indexShard = indexService.shardSafe(shardId.id()); if (request.refresh() && !request.realtime()) { indexShard.refresh("refresh_flag_mget"); } MultiGetShardResponse response = new MultiGetShardResponse(); for (int i = 0; i < request.locations.size(); i++) { MultiGetRequest.Item item = request.items.get(i); try { GetResult getResult = indexShard.getService().get(item.type(), item.id(), item.fields(), request.realtime(), item.version(), item.versionType(), item.fetchSourceContext(), request.ignoreErrorsOnGeneratedFields()); response.add(request.locations.get(i), new GetResponse(getResult)); } catch (Throwable t) { if (TransportActions.isShardNotAvailableException(t)) { throw (ElasticsearchException) t; } else { logger.debug("{} failed to execute multi_get for [{}]/[{}]", t, shardId, item.type(), item.id()); response.add(request.locations.get(i), new MultiGetResponse.Failure(request.index(), item.type(), item.id(), t)); } } } return response; }
Example 4
Source File: TransportGetAction.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override protected GetResponse shardOperation(GetRequest request, ShardId shardId) { IndexService indexService = indicesService.indexServiceSafe(shardId.getIndex()); IndexShard indexShard = indexService.shardSafe(shardId.id()); if (request.refresh() && !request.realtime()) { indexShard.refresh("refresh_flag_get"); } GetResult result = indexShard.getService().get(request.type(), request.id(), request.fields(), request.realtime(), request.version(), request.versionType(), request.fetchSourceContext(), request.ignoreErrorsOnGeneratedFields()); return new GetResponse(result); }
Example 5
Source File: TransportReplicationAction.java From Elasticsearch with Apache License 2.0 | 5 votes |
protected final void processAfterWrite(boolean refresh, IndexShard indexShard, Translog.Location location) { if (refresh) { try { indexShard.refresh("refresh_flag_index"); } catch (Throwable e) { // ignore } } if (indexShard.getTranslogDurability() == Translog.Durabilty.REQUEST && location != null) { indexShard.sync(location); } }
Example 6
Source File: IndexService.java From crate with Apache License 2.0 | 5 votes |
private void maybeRefreshEngine() { if (indexSettings.getRefreshInterval().millis() > 0) { for (IndexShard shard : this.shards.values()) { if (shard.isReadAllowed()) { try { if (shard.isRefreshNeeded()) { shard.refresh("schedule"); } } catch (IndexShardClosedException | AlreadyClosedException ex) { // fine - continue; } } } } }
Example 7
Source File: TransportShardRefreshAction.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Override protected void shardOperationOnReplica(ReplicationRequest request) { IndexShard indexShard = indicesService.indexServiceSafe(request.shardId().getIndex()).shardSafe(request.shardId().id()); indexShard.refresh("api"); logger.trace("{} refresh request executed on replica", indexShard.shardId()); }
Example 8
Source File: TransportShardRefreshAction.java From crate with Apache License 2.0 | 4 votes |
@Override protected PrimaryResult shardOperationOnPrimary(BasicReplicationRequest shardRequest, IndexShard primary) { primary.refresh("api"); logger.trace("{} refresh request executed on primary", primary.shardId()); return new PrimaryResult<>(shardRequest, new ReplicationResponse()); }
Example 9
Source File: TransportShardRefreshAction.java From crate with Apache License 2.0 | 4 votes |
@Override protected ReplicaResult shardOperationOnReplica(BasicReplicationRequest request, IndexShard replica) { replica.refresh("api"); logger.trace("{} refresh request executed on replica", replica.shardId()); return new ReplicaResult(); }