Class QueryParsing


  • public class QueryParsing
    extends Object
    Collection of static utilities useful for query parsing.
    • Constructor Detail

      • QueryParsing

        public QueryParsing()
    • Method Detail

      • parseLocalParams

        public static int parseLocalParams​(String txt,
                                           int start,
                                           org.apache.solr.common.params.ModifiableSolrParams target,
                                           org.apache.solr.common.params.SolrParams params)
                                    throws SyntaxError
        Parameters:
        txt - Text to parse
        start - Index into text for start of parsing
        target - Object to inject with parsed settings
        params - Additional existing parameters
        Throws:
        SyntaxError
      • parseLocalParams

        public static int parseLocalParams​(String txt,
                                           int start,
                                           org.apache.solr.common.params.ModifiableSolrParams target,
                                           org.apache.solr.common.params.SolrParams params,
                                           String startString,
                                           char endChar)
                                    throws SyntaxError
        Parameters:
        txt - Text to parse
        start - Index into text for start of parsing
        target - Object to inject with parsed settings
        params - Additional existing parameters
        startString - String that indicates the start of a localParams section
        endChar - Character that indicates the end of a localParams section
        Throws:
        SyntaxError
      • getLocalParams

        public static org.apache.solr.common.params.SolrParams getLocalParams​(String txt,
                                                                              org.apache.solr.common.params.SolrParams params)
                                                                       throws SyntaxError
        "foo" returns null "{!prefix f=myfield}yes" returns type="prefix",f="myfield",v="yes" "{!prefix f=myfield v=$p}" returns type="prefix",f="myfield",v=params.get("p")
        Throws:
        SyntaxError
      • toString

        public static String toString​(org.apache.lucene.search.Query query,
                                      IndexSchema schema)
        Formats a Query for debugging, using the IndexSchema to make complex field types readable.

        The benefit of using this method instead of calling Query.toString directly is that it knows about the data types of each field, so any field which is encoded in a particularly complex way is still readable. The downside is that it only knows about built in Query types, and will not be able to format custom Query classes.

      • toString

        public static List<String> toString​(List<org.apache.lucene.search.Query> queries,
                                            IndexSchema schema)
        Builds a list of String which are stringified versions of a list of Queries
      • parseOP

        public static QueryParser.Operator parseOP​(String operator)
        Parses default operator string into Operator object
        Parameters:
        operator - the string from request
        Returns:
        Operator.AND if string equals "AND", else return Operator.OR (default)