org.apache.lucene.queryparser.ext

Class Extensions

    • Method Detail

      • add

        public void add(String key,
                        ParserExtension extension)
        Adds a new ParserExtension instance associated with the given key.
        Parameters:
        key - the parser extension key
        extension - the parser extension
      • getExtension

        public final ParserExtension getExtension(String key)
        Returns the ParserExtension instance for the given key or null if no extension can be found for the key.
        Parameters:
        key - the extension key
        Returns:
        the ParserExtension instance for the given key or null if no extension can be found for the key.
      • getExtensionFieldDelimiter

        public char getExtensionFieldDelimiter()
        Returns the extension field delimiter
        Returns:
        the extension field delimiter
      • splitExtensionField

        public Extensions.Pair<String,StringsplitExtensionField(String defaultField,
                                                                  String field)
        Splits a extension field and returns the field / extension part as a Extensions.Pair. This method tries to split on the first occurrence of the extension field delimiter, if the delimiter is not present in the string the result will contain a null value for the extension key and the given field string as the field value. If the given extension field string contains no field identifier the result pair will carry the given default field as the field value.
        Parameters:
        defaultField - the default query field
        field - the extension field string
        Returns:
        a Extensions.Pair with the field name as the Extensions.Pair.cur and the extension key as the Extensions.Pair.cud
      • escapeExtensionField

        public String escapeExtensionField(String extfield)
        Escapes an extension field. The default implementation is equivalent to QueryParserBase.escape(String).
        Parameters:
        extfield - the extension field identifier
        Returns:
        the extension field identifier with all special chars escaped with a backslash character.
      • buildExtensionField

        public String buildExtensionField(String extensionKey)
        Builds an extension field string from a given extension key and the default query field. The default field and the key are delimited with the extension field delimiter character. This method makes no assumption about the order of the extension key and the field. By default the extension key is appended to the end of the returned string while the field is added to the beginning. Special Query characters are escaped in the result.

        Note: Extensions subclasses must maintain the contract between buildExtensionField(String) and splitExtensionField(String, String) where the latter inverts the former.

      • buildExtensionField

        public String buildExtensionField(String extensionKey,
                                          String field)
        Builds an extension field string from a given extension key and the extensions field. The field and the key are delimited with the extension field delimiter character. This method makes no assumption about the order of the extension key and the field. By default the extension key is appended to the end of the returned string while the field is added to the beginning. Special Query characters are escaped in the result.

        Note: Extensions subclasses must maintain the contract between buildExtensionField(String, String) and splitExtensionField(String, String) where the latter inverts the former.

        Parameters:
        extensionKey - the extension key
        field - the field to apply the extension on.
        Returns:
        escaped extension field identifier
        See Also:
        to use the default query field