Class LongField

    • Constructor Detail

      • LongField

        public LongField​(String name,
                         long value,
                         Field.Store stored)
        Creates a new LongField, indexing the provided point, storing it as a DocValue, and optionally storing it as a stored field.
        Parameters:
        name - field name
        value - the long value
        stored - whether to store the field
        Throws:
        IllegalArgumentException - if the field name or value is null.
    • Method Detail

      • toString

        public String toString()
        Description copied from class: Field
        Prints a Field for human consumption.
        Overrides:
        toString in class Field
      • newExactQuery

        public static Query newExactQuery​(String field,
                                          long value)
        Create a query for matching an exact long value.
        Parameters:
        field - field name. must not be null.
        value - exact value
        Returns:
        a query matching documents with this exact value
        Throws:
        IllegalArgumentException - if field is null.
      • newRangeQuery

        public static Query newRangeQuery​(String field,
                                          long lowerValue,
                                          long upperValue)
        Create a range query for long values.

        You can have half-open ranges (which are in fact </≤ or >/≥ queries) by setting lowerValue = Long.MIN_VALUE or upperValue = Long.MAX_VALUE.

        Ranges are inclusive. For exclusive ranges, pass Math.addExact(lowerValue, 1) or Math.addExact(upperValue, -1).

        Parameters:
        field - field name. must not be null.
        lowerValue - lower portion of the range (inclusive).
        upperValue - upper portion of the range (inclusive).
        Returns:
        a query matching documents within this range.
        Throws:
        IllegalArgumentException - if field is null.
      • newSetQuery

        public static Query newSetQuery​(String field,
                                        long... values)
        Create a query matching values in a supplied set
        Parameters:
        field - field name. must not be null.
        values - long values
        Returns:
        a query matching documents within this set.
        Throws:
        IllegalArgumentException - if field is null.
      • newSortField

        public static SortField newSortField​(String field,
                                             boolean reverse,
                                             SortedNumericSelector.Type selector)
        Create a new SortField for long values.
        Parameters:
        field - field name. must not be null.
        reverse - true if natural order should be reversed.
        selector - custom selector type for choosing the sort value from the set.
      • newDistanceFeatureQuery

        public static Query newDistanceFeatureQuery​(String field,
                                                    float weight,
                                                    long origin,
                                                    long pivotDistance)
        Returns a query that scores documents based on their distance to origin: score = weight * pivotDistance / (pivotDistance + distance), ie. score is in the [0, weight] range, is equal to weight when the document's value is equal to origin and is equal to weight/2 when the document's value is distant of pivotDistance from origin. In case of multi-valued fields, only the closest point to origin will be considered. This query is typically useful to boost results based on recency by adding this query to a BooleanClause.Occur.SHOULD clause of a BooleanQuery.