Class SpanNearQueryBuilder.SpanGapQueryBuilder

java.lang.Object
org.elasticsearch.index.query.SpanNearQueryBuilder.SpanGapQueryBuilder
All Implemented Interfaces:
NamedWriteable, Writeable, ToXContent, ToXContentObject, QueryBuilder, Rewriteable<QueryBuilder>, SpanQueryBuilder
Enclosing class:
SpanNearQueryBuilder

public static class SpanNearQueryBuilder.SpanGapQueryBuilder
extends java.lang.Object
implements SpanQueryBuilder
SpanGapQueryBuilder enables gaps in a SpanNearQuery. Since, SpanGapQuery is private to SpanNearQuery, SpanGapQueryBuilder cannot be used to generate a Query (SpanGapQuery) like another QueryBuilder. Instead, it just identifies a span_gap clause so that SpanNearQuery.addGap(int) can be invoked for it. This QueryBuilder is only applicable as a clause in SpanGapQueryBuilder but yet to enforce this restriction.
  • Field Details

  • Constructor Details

    • SpanGapQueryBuilder

      public SpanGapQueryBuilder​(java.lang.String fieldName, int width)
      Constructs a new SpanGapQueryBuilder term query.
      Parameters:
      fieldName - The name of the field
      width - The width of the gap introduced
    • SpanGapQueryBuilder

      public SpanGapQueryBuilder​(StreamInput in) throws java.io.IOException
      Read from a stream.
      Throws:
      java.io.IOException
  • Method Details

    • fieldName

      public java.lang.String fieldName()
      Returns:
      fieldName The name of the field
    • width

      public int width()
      Returns:
      width The width of the gap introduced
    • toQuery

      public org.apache.lucene.search.Query toQuery​(QueryShardContext context) throws java.io.IOException
      Description copied from interface: QueryBuilder
      Converts this QueryBuilder to a lucene Query. Returns null if this query should be ignored in the context of parent queries.
      Specified by:
      toQuery in interface QueryBuilder
      Parameters:
      context - additional information needed to construct the queries
      Returns:
      the Query or null if this query should be ignored upstream
      Throws:
      java.io.IOException
    • queryName

      public java.lang.String queryName()
      Description copied from interface: QueryBuilder
      Returns the arbitrary name assigned to the query (see named queries).
      Specified by:
      queryName in interface QueryBuilder
    • queryName

      public QueryBuilder queryName​(java.lang.String queryName)
      Description copied from interface: QueryBuilder
      Sets the arbitrary name to be assigned to the query (see named queries). Implementers should return the concrete type of the QueryBuilder so that calls can be chained. This is done automatically when extending AbstractQueryBuilder.
      Specified by:
      queryName in interface QueryBuilder
    • boost

      public float boost()
      Description copied from interface: QueryBuilder
      Returns the boost for this query.
      Specified by:
      boost in interface QueryBuilder
    • boost

      public QueryBuilder boost​(float boost)
      Description copied from interface: QueryBuilder
      Sets the boost for this query. Documents matching this query will (in addition to the normal weightings) have their score multiplied by the boost provided. Implementers should return the concrete type of the QueryBuilder so that calls can be chained. This is done automatically when extending AbstractQueryBuilder.
      Specified by:
      boost in interface QueryBuilder
    • getName

      public java.lang.String getName()
      Description copied from interface: QueryBuilder
      Returns the name that identifies uniquely the query
      Specified by:
      getName in interface QueryBuilder
    • getWriteableName

      public java.lang.String getWriteableName()
      Description copied from interface: NamedWriteable
      Returns the name of the writeable object
      Specified by:
      getWriteableName in interface NamedWriteable
    • writeTo

      public final void writeTo​(StreamOutput out) throws java.io.IOException
      Description copied from interface: Writeable
      Write this into the StreamOutput.
      Specified by:
      writeTo in interface Writeable
      Throws:
      java.io.IOException
    • toXContent

      public XContentBuilder toXContent​(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
      Specified by:
      toXContent in interface ToXContent
      Throws:
      java.io.IOException
    • fromXContent

      public static SpanNearQueryBuilder.SpanGapQueryBuilder fromXContent​(XContentParser parser) throws java.io.IOException
      Throws:
      java.io.IOException
    • equals

      public final boolean equals​(java.lang.Object obj)
      Overrides:
      equals in class java.lang.Object
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class java.lang.Object
    • toString

      public final java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • throwParsingExceptionOnMultipleFields

      protected static void throwParsingExceptionOnMultipleFields​(java.lang.String queryName, XContentLocation contentLocation, java.lang.String processedFieldName, java.lang.String currentFieldName)