Class KeywordField

    • Constructor Detail

      • KeywordField

        public KeywordField​(String name,
                            BytesRef value,
                            Field.Store stored)
        Creates a new KeywordField.
        Parameters:
        name - field name
        value - the BytesRef value
        stored - whether to store the field
        Throws:
        IllegalArgumentException - if the field name or value is null.
      • KeywordField

        public KeywordField​(String name,
                            String value,
                            Field.Store stored)
        Creates a new KeywordField from a String value, by indexing its UTF-8 representation.
        Parameters:
        name - field name
        value - the BytesRef value
        stored - whether to store the field
        Throws:
        IllegalArgumentException - if the field name or value is null.
    • Method Detail

      • setStringValue

        public void setStringValue​(String value)
        Description copied from class: Field
        Expert: change the value of this field. This can be used during indexing to re-use a single Field instance to improve indexing speed by avoiding GC cost of new'ing and reclaiming Field instances. Typically a single Document instance is re-used as well. This helps most on small documents.

        Each Field instance should only be used once within a single Document instance. See ImproveIndexingSpeed for details.

        Overrides:
        setStringValue in class Field
      • setBytesValue

        public void setBytesValue​(BytesRef value)
        Description copied from class: Field
        Expert: change the value of this field. See Field.setStringValue(String).

        NOTE: the provided BytesRef is not copied so be sure not to change it until you're done with this field.

        Overrides:
        setBytesValue in class Field
      • newExactQuery

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

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

        public static Query newSetQuery​(String field,
                                        BytesRef... values)
        Create a query for matching any of a set of provided BytesRef values.
        Parameters:
        field - field name. must not be null.
        values - the set of values to match
        Returns:
        a query matching documents with this exact value
        Throws:
        NullPointerException - if field is null.
      • newSortField

        public static SortField newSortField​(String field,
                                             boolean reverse,
                                             SortedSetSelector.Type selector)
        Create a new SortField for BytesRef 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.