protected final boolean isSearchGuardIndexRequest() { return index.getName().equals(searchguardIndex); } }
private IndexSearcherWrapper loadFlsDlsIndexSearcherWrapper(final IndexService indexService, final ComplianceIndexingOperationListener ciol, final ComplianceConfig complianceConfig) { try { IndexSearcherWrapper flsdlsWrapper = (IndexSearcherWrapper) dlsFlsConstructor .newInstance(indexService, settings, Objects.requireNonNull(adminDns), Objects.requireNonNull(cs), Objects.requireNonNull(auditLog), Objects.requireNonNull(ciol), Objects.requireNonNull(complianceConfig)); if(log.isDebugEnabled()) { log.debug("FLS/DLS enabled for index {}", indexService.index().getName()); } return flsdlsWrapper; } catch(Exception ex) { throw new RuntimeException("Failed to enable FLS/DLS", ex); } }
Set<String> doubleIndices = lookup.get(al).getIndices().stream().map(a->a.getIndex().getName()).collect(Collectors.toSet()); _indices.removeAll(doubleIndices);
log.debug("Handle complianceConfig="+complianceConfig+"/dlsFlsAvailable: "+dlsFlsAvailable+"/auditLog="+auditLog.getClass()+" for onIndexModule() of index "+indexModule.getIndex().getName()); if (dlsFlsAvailable) { if(complianceConfig.writeHistoryEnabledForIndex(indexModule.getIndex().getName())) { ciol = ReflectionHelper.instantiateComplianceListener(complianceConfig, Objects.requireNonNull(auditLog)); indexModule.addIndexOperationListener(ciol);
private void deleteAllIndices() { ImmutableOpenMap<String, IndexMetaData> indices = elasticSearchClient.admin().cluster() .prepareState().get().getState() .getMetaData().getIndices(); indices.forEach(cursor -> { try { elasticSearchClient.admin() .indices() .delete(new DeleteIndexRequest(cursor.value.getIndex().getName())) .get(); } catch (InterruptedException | ExecutionException e) { throw new RuntimeException(e); } }); }
Index concreteIndex = pmr.getConcreteIndex(); if(concreteIndex != null && (pmr.indices() == null || pmr.indices().length == 0)) { String[] newIndices = provider.provide(new String[]{concreteIndex.getName()}, request, true); if(checkIndices(request, newIndices, true, allowEmptyIndices) == false) { return false;
@Override public void clear(String reason) { logger.debug("full cache clear, reason [{}]", reason); indicesQueryCache.clearIndex(index().getName()); }
private static void checkIndexCompatibility(IndexSettings settings, String name) { if (!settings.isSingleType()) { throw new IllegalStateException("Cannot create a field alias [" + name + "] " + "for index [" + settings.getIndex().getName() + "]. Field aliases can only " + "be specified on indexes that enforce a single mapping type."); } } }
public Builder updateBlocks(IndexMetaData indexMetaData) { // let's remove all blocks for this index and add them back -- no need to remove all individual blocks.... indices.remove(indexMetaData.getIndex().getName()); return addBlocks(indexMetaData); }
public SearchLookup lookup() { if (lookup == null) { lookup = new SearchLookup(getMapperService(), mappedFieldType -> indexFieldDataService.apply(mappedFieldType, fullyQualifiedIndex.getName()), types); } return lookup; }
private void rejectSingleIndexOperation(String aliasOrIndex, AliasOrIndex result) { String[] indexNames = new String[result.getIndices().size()]; int i = 0; for (IndexMetaData indexMetaData : result.getIndices()) { indexNames[i++] = indexMetaData.getIndex().getName(); } throw new IllegalArgumentException("Alias [" + aliasOrIndex + "] has more than one index associated with it [" + Arrays.toString(indexNames) + "], can't execute a single index op"); }
private Map<String, AliasFilter> buildPerIndexAliasFilter(SearchRequest request, ClusterState clusterState, Index[] concreteIndices, Map<String, AliasFilter> remoteAliasMap) { final Map<String, AliasFilter> aliasFilterMap = new HashMap<>(); for (Index index : concreteIndices) { clusterState.blocks().indexBlockedRaiseException(ClusterBlockLevel.READ, index.getName()); AliasFilter aliasFilter = searchService.buildAliasFilter(clusterState, index.getName(), request.indices()); assert aliasFilter != null; aliasFilterMap.put(index.getUUID(), aliasFilter); } aliasFilterMap.putAll(remoteAliasMap); return aliasFilterMap; }
public IndexMetaData index(Index index) { IndexMetaData metaData = index(index.getName()); if (metaData != null && metaData.getIndexUUID().equals(index.getUUID())) { return metaData; } return null; }
public IndexMetaData getSafe(Index index) { IndexMetaData indexMetaData = get(index.getName()); if (indexMetaData != null) { if(indexMetaData.getIndexUUID().equals(index.getUUID())) { return indexMetaData; } throw new IndexNotFoundException(index, new IllegalStateException("index uuid doesn't match expected: [" + index.getUUID() + "] but got: [" + indexMetaData.getIndexUUID() +"]")); } throw new IndexNotFoundException(index); }
public Builder put(IndexMetaData indexMetaData, boolean incrementVersion) { if (indices.get(indexMetaData.getIndex().getName()) == indexMetaData) { return this; } // if we put a new index metadata, increment its version if (incrementVersion) { indexMetaData = IndexMetaData.builder(indexMetaData).version(indexMetaData.getVersion() + 1).build(); } indices.put(indexMetaData.getIndex().getName(), indexMetaData); return this; }
public final ShardSearchTransportRequest buildShardSearchRequest(SearchShardIterator shardIt) { String clusterAlias = shardIt.getClusterAlias(); AliasFilter filter = aliasFilter.get(shardIt.shardId().getIndex().getUUID()); assert filter != null; float indexBoost = concreteIndexBoosts.getOrDefault(shardIt.shardId().getIndex().getUUID(), DEFAULT_INDEX_BOOST); String indexName = shardIt.shardId().getIndex().getName(); final String[] routings = indexRoutings.getOrDefault(indexName, Collections.emptySet()) .toArray(new String[0]); return new ShardSearchTransportRequest(shardIt.getOriginalIndices(), request, shardIt.shardId(), getNumShards(), filter, indexBoost, timeProvider.getAbsoluteStartMillis(), clusterAlias, routings); }
@Override public Query wildcardQuery(String value, @Nullable MultiTermQuery.RewriteMethod method, QueryShardContext context) { String indexName = context.getFullyQualifiedIndex().getName(); if (isSameIndex(value, indexName)) { return Queries.newMatchAllQuery(); } else { return Queries.newMatchNoDocsQuery("The index [" + indexName + "] doesn't match the provided pattern [" + value + "]."); } }
@Override protected ClusterBlockException checkBlock(PutMappingRequest request, ClusterState state) { String[] indices; if (request.getConcreteIndex() == null) { indices = indexNameExpressionResolver.concreteIndexNames(state, request); } else { indices = new String[] {request.getConcreteIndex().getName()}; } return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_WRITE, indices); }
public Builder put(IndexMetaData.Builder indexMetaDataBuilder) { // we know its a new one, increment the version and store indexMetaDataBuilder.version(indexMetaDataBuilder.version() + 1); IndexMetaData indexMetaData = indexMetaDataBuilder.build(); indices.put(indexMetaData.getIndex().getName(), indexMetaData); return this; }
/** * Returns the {@link GroupShardsIterator} for the provided <code>request</code>. */ private GroupShardsIterator<ShardIterator> buildShardIterator(ClusterService clusterService, ShardSearchRequest request) { final ClusterState state = clusterService.state(); String[] indices = new String[] { request.shardId().getIndex().getName() }; Map<String, Set<String>> routingMap = request.indexRoutings().length > 0 ? Collections.singletonMap(indices[0], Sets.newHashSet(request.indexRoutings())) : null; return clusterService.operationRouting().searchShards(state, indices, routingMap, request.preference()); }