Class AbstractOpenSearchQueryBuilder<T extends SearchQuery>

java.lang.Object
org.opencastproject.opensearch.impl.AbstractOpenSearchQueryBuilder<T>
All Implemented Interfaces:
org.opensearch.core.common.io.stream.NamedWriteable, org.opensearch.core.common.io.stream.Writeable, org.opensearch.core.xcontent.ToXContent, org.opensearch.core.xcontent.ToXContentObject, org.opensearch.index.query.QueryBuilder, org.opensearch.index.query.Rewriteable<org.opensearch.index.query.QueryBuilder>
Direct Known Subclasses:
EventQueryBuilder, SeriesQueryBuilder

public abstract class AbstractOpenSearchQueryBuilder<T extends SearchQuery> extends Object implements org.opensearch.index.query.QueryBuilder
Opencast implementation of the OpenSearch query builder.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    Utility class to hold date range specifications and turn them into OpenSearch queries.
    static final class 
    Stores a group of values which will later be added to the query using AND.

    Nested classes/interfaces inherited from interface org.opensearch.core.xcontent.ToXContent

    org.opensearch.core.xcontent.ToXContent.DelegatingMapParams, org.opensearch.core.xcontent.ToXContent.MapParams, org.opensearch.core.xcontent.ToXContent.Params

    Nested classes/interfaces inherited from interface org.opensearch.core.common.io.stream.Writeable

    org.opensearch.core.common.io.stream.Writeable.Reader<V>, org.opensearch.core.common.io.stream.Writeable.WriteableRegistry, org.opensearch.core.common.io.stream.Writeable.Writer<V>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected List<String>
     
    protected String
    Filter expression
    protected boolean
    Fuzzy text query
    Fields that need to match all values
    protected String
    Text query

    Fields inherited from interface org.opensearch.index.query.Rewriteable

    MAX_REWRITE_ROUNDS

    Fields inherited from interface org.opensearch.core.xcontent.ToXContent

    EMPTY_PARAMS
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new OpenSearch query based on the raw query.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    and(String fieldName, Object... fieldValues)
    Stores fieldValue as a search term on the fieldName field.
    protected void
    and(String fieldName, Date startDate, Date endDate)
    Stores fieldValue as a search term on the fieldName field.
    protected void
    andDateGreaterThan(String fieldName, String date)
     
    protected void
    andDateLessThan(String fieldName, String date)
     
    protected void
    andNot(String fieldName, Object... fieldValues)
    Stores fieldValue as a search term on the fieldName field.
    protected void
    andWildcard(String fieldName, String fieldValue)
    Stores fieldValue as a wildcard term on the fieldName field.
    protected void
    andWildcardNot(String fieldName, String fieldValue)
    Stores fieldValue as a wildcard term on the fieldName field.
    float
     
    org.opensearch.index.query.QueryBuilder
    boost(float boost)
     
    abstract void
    buildQuery(T query)
     
    org.opensearch.index.query.QueryBuilder
    filter(org.opensearch.index.query.QueryBuilder filter)
     
     
    Returns the original search query.
     
    boolean
     
     
    org.opensearch.index.query.QueryBuilder
    queryName(String queryName)
     
    org.opensearch.index.query.QueryBuilder
    rewrite(org.opensearch.index.query.QueryRewriteContext queryShardContext)
     
    org.apache.lucene.search.Query
    toQuery(org.opensearch.index.query.QueryShardContext context)
     
    org.opensearch.core.xcontent.XContentBuilder
    toXContent(org.opensearch.core.xcontent.XContentBuilder builder, org.opensearch.core.xcontent.ToXContent.Params params)
     
    void
    writeTo(org.opensearch.core.common.io.stream.StreamOutput out)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.opensearch.index.query.QueryBuilder

    supportsIntraSegmentSearch, visit
  • Field Details

  • Constructor Details

    • AbstractOpenSearchQueryBuilder

      public AbstractOpenSearchQueryBuilder(T query)
      Creates a new OpenSearch query based on the raw query.
      Parameters:
      query - the search query
  • Method Details

    • getQuery

      public T getQuery()
      Returns the original search query.
      Returns:
      the search query
    • buildQuery

      public abstract void buildQuery(T query)
    • and

      protected void and(String fieldName, Object... fieldValues)
      Stores fieldValue as a search term on the fieldName field.
      Parameters:
      fieldName - the field name
      fieldValues - the field value
    • andNot

      protected void andNot(String fieldName, Object... fieldValues)
      Stores fieldValue as a search term on the fieldName field.
      Parameters:
      fieldName - the field name
      fieldValues - the field value
    • andWildcard

      protected void andWildcard(String fieldName, String fieldValue)
      Stores fieldValue as a wildcard term on the fieldName field.
      Parameters:
      fieldName - the field name
      fieldValue - the field value
    • andWildcardNot

      protected void andWildcardNot(String fieldName, String fieldValue)
      Stores fieldValue as a wildcard term on the fieldName field.
      Parameters:
      fieldName - the field name
      fieldValue - the field value
    • and

      protected void and(String fieldName, Date startDate, Date endDate)
      Stores fieldValue as a search term on the fieldName field.
      Parameters:
      fieldName - the field name
      startDate - the start date
      endDate - the end date
    • andDateGreaterThan

      protected void andDateGreaterThan(String fieldName, String date)
    • andDateLessThan

      protected void andDateLessThan(String fieldName, String date)
    • toXContent

      public org.opensearch.core.xcontent.XContentBuilder toXContent(org.opensearch.core.xcontent.XContentBuilder builder, org.opensearch.core.xcontent.ToXContent.Params params) throws IOException
      Specified by:
      toXContent in interface org.opensearch.core.xcontent.ToXContent
      Throws:
      IOException
    • toQuery

      public org.apache.lucene.search.Query toQuery(org.opensearch.index.query.QueryShardContext context) throws IOException
      Specified by:
      toQuery in interface org.opensearch.index.query.QueryBuilder
      Throws:
      IOException
    • queryName

      public org.opensearch.index.query.QueryBuilder queryName(String queryName)
      Specified by:
      queryName in interface org.opensearch.index.query.QueryBuilder
    • queryName

      public String queryName()
      Specified by:
      queryName in interface org.opensearch.index.query.QueryBuilder
    • boost

      public float boost()
      Specified by:
      boost in interface org.opensearch.index.query.QueryBuilder
    • boost

      public org.opensearch.index.query.QueryBuilder boost(float boost)
      Specified by:
      boost in interface org.opensearch.index.query.QueryBuilder
    • filter

      public org.opensearch.index.query.QueryBuilder filter(org.opensearch.index.query.QueryBuilder filter)
      Specified by:
      filter in interface org.opensearch.index.query.QueryBuilder
    • getName

      public String getName()
      Specified by:
      getName in interface org.opensearch.index.query.QueryBuilder
    • getWriteableName

      public String getWriteableName()
      Specified by:
      getWriteableName in interface org.opensearch.core.common.io.stream.NamedWriteable
    • writeTo

      public void writeTo(org.opensearch.core.common.io.stream.StreamOutput out) throws IOException
      Specified by:
      writeTo in interface org.opensearch.core.common.io.stream.Writeable
      Throws:
      IOException
    • rewrite

      public org.opensearch.index.query.QueryBuilder rewrite(org.opensearch.index.query.QueryRewriteContext queryShardContext) throws IOException
      Specified by:
      rewrite in interface org.opensearch.index.query.QueryBuilder
      Specified by:
      rewrite in interface org.opensearch.index.query.Rewriteable<T extends SearchQuery>
      Throws:
      IOException
    • isFragment

      public boolean isFragment()
      Specified by:
      isFragment in interface org.opensearch.core.xcontent.ToXContent
      Specified by:
      isFragment in interface org.opensearch.core.xcontent.ToXContentObject