Class SearchIndex<E>

  • Type Parameters:
    E - the type of index
    Direct Known Subclasses:
    PEFSearchIndex

    public class SearchIndex<E>
    extends Object
    Provides a search index.
    • Constructor Detail

      • SearchIndex

        public SearchIndex()
        Creates a new search index with the default sub-word limit (3).
      • SearchIndex

        public SearchIndex​(int subwordLimit)
        Creates a new search index with the specified sub-word limit.
        Parameters:
        subwordLimit - the smallest part of a word longer than limit to be added to the index. For example, if the limit is 3, a search for "li" will not match entries containing "limit"
        Throws:
        IllegalArgumentException - if subwordLimit is < 1
    • Method Detail

      • add

        public void add​(String val,
                        E obj)
        Associates a string and (if the string length exceeds the sub word limit) its substrings with an object.
        Parameters:
        val - the string
        obj - the object
      • add

        public void add​(String val,
                        E obj,
                        boolean strict)
        Associates a string with an object.
        Parameters:
        val - the string
        obj - the object
        strict - when true, only the specified string will match the object. When false and the string length exceeds the sub word limit, substrings of the specified string will also match this object.
      • containsAll

        public Set<E> containsAll​(Iterable<String> strs)
        Returns the set of objects that matches all the specified strings.
        Parameters:
        strs - the strings
        Returns:
        returns a set of matching objects
      • containsAll

        public Set<E> containsAll​(String str)
        Returns the set of objects that matches all the character units found in the input string.
        Parameters:
        str - the string
        Returns:
        returns a set of matching objects
      • containsAll

        public Set<E> containsAll​(String... strs)
        Returns the set of objects that matches all the specified strings.
        Parameters:
        strs - the strings
        Returns:
        returns a set of matching objects