Class QueryBuilder<T>

java.lang.Object
sonia.scm.search.QueryBuilder<T>
Type Parameters:
T - type of indexed objects

@Beta public abstract class QueryBuilder<T> extends Object
Build and execute queries against an index.
Since:
2.21.0
  • Constructor Details

    • QueryBuilder

      public QueryBuilder()
  • Method Details

    • filter

      public QueryBuilder<T> filter(Class<?> type, String id)
      Return only results which are related to the given part of the id. Note: this function can be called multiple times.
      Parameters:
      type - type of id part
      id - value of id part
      Returns:
      this
      Since:
      2.23.0
      See Also:
    • filter

      public QueryBuilder<T> filter(Repository repository)
      Return only results which are related to the given repository.
      Parameters:
      repository - repository for filter
      Returns:
      this
      Since:
      2.23.0
      See Also:
    • filter

      public QueryBuilder<T> filter(Class<?> type, ModelObject idObject)
      Return only results which are related to the given part of the id. Note: this function can be called multiple times.
      Parameters:
      type - type of id part
      idObject - object which holds the id value
      Returns:
      this
      Since:
      2.23.0
      See Also:
    • start

      public QueryBuilder<T> start(int start)
      The result should start at the given number. All matching objects before the given start are skipped.
      Parameters:
      start - start of result
      Returns:
      this
    • limit

      public QueryBuilder<T> limit(int limit)
      Defines how many hits are returned.
      Parameters:
      limit - limit of hits
      Returns:
      this
    • execute

      public QueryResult execute(String queryString)
      Executes the query and returns the matches.
      Parameters:
      queryString - searched query
      Returns:
      result of query
    • count

      public QueryCountResult count(String queryString)
      Executes the query and returns the total count of hits.
      Parameters:
      queryString - searched query
      Returns:
      total count of hits
      Since:
      2.22.0
    • execute

      protected abstract QueryResult execute(sonia.scm.search.QueryBuilder.QueryParams queryParams)
      Executes the query and returns the matches.
      Parameters:
      queryParams - query parameter
      Returns:
      result of query
    • count

      protected QueryCountResult count(sonia.scm.search.QueryBuilder.QueryParams queryParams)
      Executes the query and returns the total count of hits.
      Parameters:
      queryParams - query parameter
      Returns:
      total hit count
      Since:
      2.22.0