Tabnine Logo
org.elasticsearch.action.support
Code IndexAdd Tabnine to your IDE (free)

How to use org.elasticsearch.action.support

Best Java code snippets using org.elasticsearch.action.support (Showing top 20 results out of 315)

origin: spring-projects/spring-data-elasticsearch

/**
 * Pre process the write request before it is sent to the server, eg. by setting the
 * {@link WriteRequest#setRefreshPolicy(String) refresh policy} if applicable.
 *
 * @param request must not be {@literal null}.
 * @param <R>
 * @return the processed {@link WriteRequest}.
 */
protected <R extends WriteRequest<R>> R prepareWriteRequest(R request) {
  if (refreshPolicy == null) {
    return request;
  }
  return request.setRefreshPolicy(refreshPolicy);
}
origin: spring-projects/spring-data-elasticsearch

/**
 * Set up the read {@link IndicesOptions}. Default is set to {@link IndicesOptions#strictExpandOpenAndForbidClosed()}.
 *
 * @return {@literal null} to use the server defaults.
 */
@Nullable
protected IndicesOptions indicesOptions() {
  return IndicesOptions.strictExpandOpenAndForbidClosed();
}
origin: spring-projects/spring-data-elasticsearch

Params withRefreshPolicy(RefreshPolicy refreshPolicy) {
  if (refreshPolicy != RefreshPolicy.NONE) {
    return putParam("refresh", refreshPolicy.getValue());
  }
  return this;
}
origin: spring-projects/spring-data-elasticsearch

Params withIndicesOptions(IndicesOptions indicesOptions) {
  withIgnoreUnavailable(indicesOptions.ignoreUnavailable());
  putParam("allow_no_indices", Boolean.toString(indicesOptions.allowNoIndices()));
  String expandWildcards;
  if (!indicesOptions.expandWildcardsOpen() && !indicesOptions.expandWildcardsClosed()) {
    expandWildcards = "none";
  } else {
    StringJoiner joiner = new StringJoiner(",");
    if (indicesOptions.expandWildcardsOpen()) {
      joiner.add("open");
    }
    if (indicesOptions.expandWildcardsClosed()) {
      joiner.add("closed");
    }
    expandWildcards = joiner.toString();
  }
  putParam("expand_wildcards", expandWildcards);
  return this;
}
origin: floragunncom/search-guard

  @Override
  public String[] provide(String[] original, Object request, boolean supportsReplace) {
    if(supportsReplace) {
      if(retainMode && original != null && original.length > 0) {
        //TODO datemath?
        List<String> originalAsList = Arrays.asList(original);
        if(originalAsList.contains("*") || originalAsList.contains("_all")) {
          return replacements;
        }
        
        original = resolver.concreteIndexNames(clusterService.state(), IndicesOptions.lenientExpandOpen(), original);
        
        final String[] retained = WildcardMatcher.getMatchAny(original, replacements).toArray(new String[0]);
        return retained;
      }
      return replacements;
    } else {
      return NOOP;
    }
  }
}, false);
origin: NLPchina/elasticsearch-sql

protected void updateRequestWithIndexAndRoutingOptions(Select select, SearchRequestBuilder request) {
  for (Hint hint : select.getHints()) {
    if (hint.getType() == HintType.IGNORE_UNAVAILABLE) {
      //saving the defaults from TransportClient search
      request.setIndicesOptions(IndicesOptions.fromOptions(true, false, true, false, IndicesOptions.strictExpandOpenAndForbidClosed()));
    }
    if (hint.getType() == HintType.ROUTINGS) {
      Object[] routings = hint.getParams();
      String[] routingsAsStringArray = new String[routings.length];
      for (int i = 0; i < routings.length; i++) {
        routingsAsStringArray[i] = routings[i].toString();
      }
      request.setRouting(routingsAsStringArray);
    }
  }
}
origin: org.elasticsearch/elasticsearch

@Override
public final <Request extends ActionRequest, Response extends ActionResponse> void apply(Task task, String action, Request request,
    ActionListener<Response> listener, ActionFilterChain<Request, Response> chain) {
  if (apply(action, request, listener)) {
    chain.proceed(task, action, request, listener);
  }
}
origin: org.elasticsearch/elasticsearch

public final ActionFuture<Response> execute(Request request) {
  PlainActionFuture<Response> future = newFuture();
  execute(request, future);
  return future;
}
origin: org.elasticsearch/elasticsearch

  /**
   * Parse the refresh policy from a string, only modifying it if the string is non null. Convenient to use with request parsing.
   */
  @SuppressWarnings("unchecked")
  default B setRefreshPolicy(String refreshPolicy) {
    request().setRefreshPolicy(refreshPolicy);
    return (B) this;
  }
}
origin: org.elasticsearch/elasticsearch

/**
 * Parse the refresh policy from a string, only modifying it if the string is non null. Convenient to use with request parsing.
 */
@SuppressWarnings("unchecked")
default R setRefreshPolicy(String refreshPolicy) {
  if (refreshPolicy != null) {
    setRefreshPolicy(RefreshPolicy.parse(refreshPolicy));
  }
  return (R) this;
}
origin: floragunncom/search-guard

_indices = new ArrayList<>(Arrays.asList(resolver.concreteIndexNames(state, IndicesOptions.fromOptions(false, true, true, false), requestedPatterns)));
if (log.isDebugEnabled()) {
  log.debug("Resolved pattern {} to {}", requestedPatterns, _indices);
origin: spring-projects/spring-data-elasticsearch

Params withWaitForActiveShards(ActiveShardCount activeShardCount, ActiveShardCount defaultActiveShardCount) {
  if (activeShardCount != null && activeShardCount != defaultActiveShardCount) {
    return putParam("wait_for_active_shards", activeShardCount.toString().toLowerCase(Locale.ROOT));
  }
  return this;
}
origin: org.elasticsearch/elasticsearch

  @Override
  public void addListener(final ActionListener<T> listener) {
    super.addListener(new ThreadedActionListener<>(logger, threadPool, ThreadPool.Names.LISTENER, listener, false));
  }
}
origin: org.elasticsearch/elasticsearch

/**
 * If a failure is already present, should this failure override it or not for read operations.
 */
public static boolean isReadOverrideException(Exception e) {
  return !isShardNotAvailableException(e);
}
origin: org.elasticsearch/elasticsearch

/**
 * This method returns a listenable future. The listeners will be called on completion of the future.
 * The listeners will be executed by the same thread that completes the future.
 *
 * @param <T> the result of the future
 * @return a listenable future
 */
public static <T> PlainListenableActionFuture<T> newListenableFuture() {
  return new PlainListenableActionFuture<>();
}
origin: org.elasticsearch/elasticsearch

/**
 * The REST status that should be used for the response
 */
public RestStatus getStatus() {
  if (failedShards > 0) {
    return shardFailures[0].status();
  } else {
    return RestStatus.OK;
  }
}
origin: spring-projects/spring-data-elasticsearch

/**
 * Customization hook to modify a generated {@link DeleteByQueryRequest} prior to its execution. Eg. by setting the
 * {@link WriteRequest#setRefreshPolicy(String) refresh policy} if applicable.
 *
 * @param request the generated {@link DeleteByQueryRequest}.
 * @return never {@literal null}.
 */
protected DeleteByQueryRequest prepareDeleteByRequest(DeleteByQueryRequest request) {
  if (refreshPolicy != null && !RefreshPolicy.NONE.equals(refreshPolicy)) {
    request = request.setRefresh(true);
  }
  if (indicesOptions != null) {
    request = request.setIndicesOptions(indicesOptions);
  }
  return request;
}
origin: floragunncom/search-guard

final String[] allIndices = resolver.concreteIndexNames(cs.state(), IndicesOptions.lenientExpandOpen(), "*");
final Set<String> wanted = new HashSet<>(Arrays.asList(allIndices));
WildcardMatcher.wildcardRetainInSet(wanted, permitted);
origin: org.elasticsearch/elasticsearch

/**
 * Should this request trigger a refresh ({@linkplain RefreshPolicy#IMMEDIATE}), wait for a refresh (
 * {@linkplain RefreshPolicy#WAIT_UNTIL}), or proceed ignore refreshes entirely ({@linkplain RefreshPolicy#NONE}, the default).
 */
@SuppressWarnings("unchecked")
default B setRefreshPolicy(RefreshPolicy refreshPolicy) {
  request().setRefreshPolicy(refreshPolicy);
  return (B) this;
}
origin: floragunncom/search-guard

private String[] getResolvedIndexPattern(User user, IndexNameExpressionResolver resolver, ClusterService cs) {
  String unresolved = getUnresolvedIndexPattern(user);
  String[] resolved = null;
  if(WildcardMatcher.containsWildcard(unresolved)) {
    final String[] aliasesForPermittedPattern = cs.state().getMetaData().getAliasAndIndexLookup()        
        .entrySet().stream()
        .filter(e->e.getValue().isAlias())
        .filter(e->WildcardMatcher.match(unresolved, e.getKey()))
        .map(e->e.getKey()).toArray(String[]::new);
    
    if(aliasesForPermittedPattern != null && aliasesForPermittedPattern.length > 0) {
      resolved = resolver.concreteIndexNames(cs.state(), IndicesOptions.lenientExpandOpen(), aliasesForPermittedPattern);
    }
  }
  
  if(resolved == null && !unresolved.isEmpty()) {
    resolved = resolver.concreteIndexNames(cs.state(), IndicesOptions.lenientExpandOpen(), unresolved);
  }
  if(resolved == null || resolved.length == 0) {
    return new String[]{unresolved};
  } else {
    //append unresolved value for pattern matching
    String[] retval = Arrays.copyOf(resolved, resolved.length +1);
    retval[retval.length-1] = unresolved;
    return retval;
  }
}
org.elasticsearch.action.support

Most used classes

  • IndicesOptions
    Controls how to deal with unavailable concrete indices (closed or missing), how wildcard expressions
  • AcknowledgedResponse
    A response that indicates that a request has been acknowledged
  • DefaultShardOperationFailedException
  • PlainActionFuture
  • ActionFilterChain
    A filter chain allowing to continue and process the transport action request
  • ActiveShardCount,
  • AutoCreateIndex,
  • WriteRequest$RefreshPolicy,
  • BaseTasksRequest,
  • TransportAction,
  • BroadcastResponse,
  • BaseNodeRequest,
  • BaseNodeResponse,
  • TransportSingleShardAction$InternalRequest,
  • TransportSingleShardAction,
  • ActionFilters,
  • BroadcastRequest,
  • BroadcastShardRequest,
  • BroadcastShardResponse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now