Interface QueryService

All Superinterfaces:
Service

public interface QueryService extends Service
Service to execute VQL queries.
  • Method Details

    • query

      @Deprecated QueryResponse query(String vqlQuery)
      Deprecated.
      as of 21R3.4, replaced by query(QueryExecutionRequest)
      Executes the given vqlQuery.
      Parameters:
      vqlQuery - VQL query to execute
      Returns:
      query execution response
    • query

      Creates an operation to execute the given queryExecutionRequest. You can specify the ways success and error responses are handled on the returned QueryOperation. Once success-handling and error-handling are specified, you can call QueryOperation.execute() to execute the query request. For example:
       queryService.query(queryExecutionRequest)
        .onSuccess(queryExecutionResponse -> {
            queryExecutionResponse.streamResults().forEach( ... )
        })
        .execute()

      The stream returned by QueryExecutionResponse.streamResults() includes all results qualified by the query. Therefore, this method does not support the VQL pagination clauses PAGESIZE and PAGEOFFSET.

      Parameters:
      queryExecutionRequest - query request to execute
      Returns:
      operation used to execute the query execution request
      Since:
      21R3.4
    • count

      Creates an operation to count the records qualified by the given queryCountRequest. You can specify the ways success and error are handled on the returned QueryOperation. Once success-handling and error-handling is specified, you can call QueryOperation.execute() to execute the query request. For example:
       queryService.count(queryCountRequest)
        .onSuccess(queryCountResponse -> {
            queryCountResponse.getCount()
            ...
        })
        .execute()
      Parameters:
      queryCountRequest - query count request to execute
      Returns:
      operation used to count the records qualified by the query count request
    • validate

      Creates an operation to validate the given queryValidationRequest. You can specify the ways success and error are handled on the returned QueryOperation. Once success-handling and error-handling is specified, you can call QueryOperation.execute() to execute the query request. For example:
       queryService.validate(queryValidationRequest)
        .onSuccess(queryValidationResponse -> {
            queryValidationResponse.getQuery()
            ...
        })
        .execute()
      Parameters:
      queryValidationRequest - query validation request to execute
      Returns:
      operation used to validate the query validation request
    • newQueryExecutionRequestBuilder

      QueryExecutionRequest.Builder newQueryExecutionRequestBuilder()
      Returns:
      a QueryRequest builder
    • newQueryCountRequestBuilder

      QueryCountRequest.Builder newQueryCountRequestBuilder()
      Returns:
      a QueryCountRequest builder
    • newQueryValidationRequestBuilder

      QueryValidationRequest.Builder newQueryValidationRequestBuilder()
      Returns:
      a QueryValidationRequest builder
    • newQueryBuilder

      Query.Builder newQueryBuilder()
      Retrieves a Query.Builder.
      Returns:
      a Query builder
    • newQueryBuilderFromQuery

      Query.Builder newQueryBuilderFromQuery(Query query)
      Creates a Query.Builder based on a Query.
      Parameters:
      query - Query with which to populate the returned builder
      Returns:
      a Query builder based on the given query
    • escape

      @Deprecated String escape(String value)
      Deprecated.
      This method only escapes single quotes and backslashes and does not provide a way to escape other special characters. As of 21R3.4, the preferred escape utility is escapeValue(String, QueryEscapeOverride...) which escapes all VQL special characters by default and supports overriding the default escape strategy.
      Escapes special characters in a string for use in a VQL statement.

      Escaped characters include single quotes and backslashes. This method does not escape reserved keywords, such as SELECT or WHERE.

      All user-provided values should be escaped to ensure your queries execute as expected. For example, in the following VQL statement:

       SELECT id FROM user__sys WHERE name__v='O'Brien'
       
      The name value is a user-entered value which, if not escaped, could cause the VQL parser to fail because of the special character.

      Note that improperly escaped VQL will not bypass configured security.

      Parameters:
      value - the value to escape
      Returns:
      the escaped value
    • escapeValue

      String escapeValue(String value, QueryEscapeOverride... escapeOverrides)
      Escapes all VQL special characters in a string for use in a VQL statement.

      VQL special characters are:

      \ " ' ( ) * %

      Optionally, any number of QueryEscapeOverride can be used to exempt certain special characters from being escaped.

      Parameters:
      value - the value to escape
      escapeOverrides - overrides(s) indicating which characters not to escape
      Returns:
      the escaped value