Class AbstractElasticsearchQueryBuilder<T extends SearchQuery>

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

public abstract class AbstractElasticsearchQueryBuilder<T extends SearchQuery> extends Object implements org.elasticsearch.index.query.QueryBuilder
Opencast implementation of the elastic search 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 elastic search 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.elasticsearch.common.xcontent.ToXContent

    org.elasticsearch.common.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.common.xcontent.ToXContent.MapParams, org.elasticsearch.common.xcontent.ToXContent.Params

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

    org.elasticsearch.common.io.stream.Writeable.Reader<V>, org.elasticsearch.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.elasticsearch.index.query.Rewriteable

    MAX_REWRITE_ROUNDS

    Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent

    EMPTY_PARAMS
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new elastic search 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.
    float
     
    org.elasticsearch.index.query.QueryBuilder
    boost(float boost)
     
    abstract void
    buildQuery(T query)
     
     
    Returns the original search query.
     
    boolean
     
     
    org.elasticsearch.index.query.QueryBuilder
    queryName(String queryName)
     
    org.elasticsearch.index.query.QueryBuilder
    rewrite(org.elasticsearch.index.query.QueryRewriteContext queryShardContext)
     
    org.apache.lucene.search.Query
    toQuery(org.elasticsearch.index.query.QueryShardContext context)
     
    org.elasticsearch.common.xcontent.XContentBuilder
    toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)
     
    void
    writeTo(org.elasticsearch.common.io.stream.StreamOutput out)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • AbstractElasticsearchQueryBuilder

      public AbstractElasticsearchQueryBuilder(T query)
      Creates a new elastic search 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
    • 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
    • toXContent

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

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

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

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

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

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

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

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

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

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

      public boolean isFragment()
      Specified by:
      isFragment in interface org.elasticsearch.common.xcontent.ToXContent
      Specified by:
      isFragment in interface org.elasticsearch.common.xcontent.ToXContentObject