Class XMLQueryParser

java.lang.Object
org.dlese.dpc.index.queryParser.XMLQueryParser

public class XMLQueryParser extends Object
Creates a Lucene Query from an XML representation of a query. See sample Query XML file . Currently supports term, phrase, boolean and Lucene query syntax formatted queries, with option to set the boost factor assigned to any query (default boost is 1.0). If a Lucene query syntax based query may be found in the Query XML, then a Lucene QueryParser must be supplied, otherwise it may be ommitted.
Author:
John Weatherley
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.apache.lucene.search.Query
    getLuceneQuery(File queryXml, org.apache.lucene.queryParser.QueryParser queryParser)
    Gets the Lucene Query representation for the given XML Query.
    static org.apache.lucene.search.Query
    getLuceneQuery(String queryXml, org.apache.lucene.queryParser.QueryParser queryParser)
    Gets the Lucene Query representation for the given XML Query.
    static org.apache.lucene.search.Query
    getLuceneQuery(URL queryXml, org.apache.lucene.queryParser.QueryParser queryParser)
    Gets the Lucene Query representation for the given XML Query.
    static org.apache.lucene.search.Query
    getLuceneQuery(org.dom4j.Element queryElement, org.apache.lucene.queryParser.QueryParser queryParser)
    Gets the Lucene Query representation for the given XML Query starting at the Query element.
    static String
    getQueryString(String queryXml, org.apache.lucene.queryParser.QueryParser queryParser)
    Gets the Lucene query String representation for the given XML Query.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • XMLQueryParser

      public XMLQueryParser()
  • Method Details

    • getQueryString

      public static String getQueryString(String queryXml, org.apache.lucene.queryParser.QueryParser queryParser) throws Exception
      Gets the Lucene query String representation for the given XML Query.
      Parameters:
      queryXml - A XML Query
      queryParser - QueryParser used to parse Lucene syntax based queries and tokenize the text
      Returns:
      The queryString value
      Throws:
      Exception - If error
    • getLuceneQuery

      public static org.apache.lucene.search.Query getLuceneQuery(File queryXml, org.apache.lucene.queryParser.QueryParser queryParser) throws Exception
      Gets the Lucene Query representation for the given XML Query.
      Parameters:
      queryXml - A file containing an XML Query
      queryParser - QueryParser used to parse Lucene syntax based queries and tokenize the text
      Returns:
      The Lucene Query object representation of this XML Query
      Throws:
      Exception - If error
    • getLuceneQuery

      public static org.apache.lucene.search.Query getLuceneQuery(URL queryXml, org.apache.lucene.queryParser.QueryParser queryParser) throws Exception
      Gets the Lucene Query representation for the given XML Query.
      Parameters:
      queryXml - A URL to a file containing an XML Query
      queryParser - QueryParser used to parse Lucene syntax based queries and tokenize the text
      Returns:
      The Lucene Query object representation of this XML Query
      Throws:
      Exception - If error
    • getLuceneQuery

      public static org.apache.lucene.search.Query getLuceneQuery(String queryXml, org.apache.lucene.queryParser.QueryParser queryParser) throws Exception
      Gets the Lucene Query representation for the given XML Query.
      Parameters:
      queryXml - An XML Query
      queryParser - QueryParser used to parse Lucene syntax based queries and tokenize the text
      Returns:
      The Lucene Query object representation of this XML Query
      Throws:
      Exception - If error
    • getLuceneQuery

      public static org.apache.lucene.search.Query getLuceneQuery(org.dom4j.Element queryElement, org.apache.lucene.queryParser.QueryParser queryParser) throws Exception
      Gets the Lucene Query representation for the given XML Query starting at the Query element.
      Parameters:
      queryElement - A dom4j representation of the Query element
      queryParser - QueryParser used to parse Lucene syntax based queries and tokenize the text
      Returns:
      The Lucene Query object representation of this XML Query
      Throws:
      Exception - If error