Class XmlQParserPlugin

java.lang.Object
org.apache.solr.search.QParserPlugin
org.apache.solr.search.XmlQParserPlugin
All Implemented Interfaces:
AutoCloseable, SolrInfoBean, SolrMetricProducer, NamedListInitializedPlugin

public class XmlQParserPlugin extends QParserPlugin
The XmlQParserPlugin extends the QParserPlugin and supports the creation of queries from XML.

Example:

 <BooleanQuery fieldName="description">
 <Clause occurs="must">
 <TermQuery>shirt</TermQuery>
 </Clause>
 <Clause occurs="mustnot">
 <TermQuery>plain</TermQuery>
 </Clause>
 <Clause occurs="should">
 <TermQuery>cotton</TermQuery>
 </Clause>
 <Clause occurs="must">
 <BooleanQuery fieldName="size">
 <Clause occurs="should">
 <TermsQuery>S M L</TermsQuery>
 </Clause>
 </BooleanQuery>
 </Clause>
 </BooleanQuery>
 
You can configure your own custom query builders for additional XML elements. The custom builders need to extend the SolrQueryBuilder or the SolrSpanQueryBuilder class.

Example solrconfig.xml snippet:

<queryParser name="xmlparser" class="XmlQParserPlugin">
 <str name="MyCustomQuery">com.mycompany.solr.search.MyCustomQueryBuilder</str>
 </queryParser>
 
  • Field Details

  • Constructor Details

    • XmlQParserPlugin

      public XmlQParserPlugin()
  • Method Details

    • init

      public void init(org.apache.solr.common.util.NamedList<?> args)
      Description copied from interface: NamedListInitializedPlugin
      init will be called just once, immediately after creation.

      Source of the initialization arguments will typically be solrconfig.xml, but will ultimately depends on the plugin itself

      Parameters:
      args - non-null list of initialization parameters (may be empty)
    • createParser

      public QParser createParser(String qstr, org.apache.solr.common.params.SolrParams localParams, org.apache.solr.common.params.SolrParams params, SolrQueryRequest req)
      Description copied from class: QParserPlugin
      return a QParser
      Specified by:
      createParser in class QParserPlugin