.. _querqy4-for-solr: ================= Querqy 4 for Solr ================= This page documents Querqy 4 for Solr. Querqy 4 has been superseded by the current version of Querqy for Solr, which manages rewriter configurations via a REST API rather than ``solrconfig.xml``. If you are running Querqy 4 and considering an upgrade, see the :doc:`migration guide `. Installation ============ Add the Querqy query parser and query component to your ``solrconfig.xml``: .. code-block:: xml Making Queries ============== The Querqy query parser is enabled using the ``defType`` parameter: ``/solr/mycollection/select?q=notebook&defType=querqy&qf=title^3.0 brand^2.1 shortSummary`` The rewrite chain configured in ``solrconfig.xml`` is automatically applied to every request. Configuring Rewriters ===================== In Querqy 4, rewriters are configured as child elements of the query parser in ``solrconfig.xml``. Together they form the rewrite chain, applied in the order in which they are defined: .. code-block:: xml :linenos: :emphasize-lines: 6,8-22 commonRules querqy.solr.SimpleCommonRulesRewriterFactory rules.txt The ``lst`` element ``rewriteChain`` (line #6) serves as a container for the rewriters. Each rewriter is defined in a ``rewriter`` ``lst`` element (#11). All rewriters must have a ``class`` property (#15) that specifies a factory for creating the rewriter. The ``id`` property (#13) is optional. In some cases the id is used to route request parameters to a specific rewriter. The 'id' and 'class' properties are the only properties that are available for all rewriters. Rewriters can have additional properties that will only have a meaning for the specific rewriter implementation. In the example, the ``rules`` property specifies the resource that contains rule definitions for the 'Common Rules Rewriter'. Resources are files that are either kept in ZooKeeper as part of the configset (SolrCloud) or in the 'conf' folder of a Solr core in standalone or master-slave Solr. They can be gzipped, which will be auto-detected by Querqy, regardless of the file name. If you keep your files in ZooKeeper, remember the maximum file size in ZooKeeper (default: 1 MB). Rewriter Configurations ======================= Common Rules Rewriter --------------------- The rules for the Common Rules Rewriter are maintained in the resource configured as the ``rules`` property of the ``SimpleCommonRulesRewriterFactory``: .. code-block:: xml :linenos: :emphasize-lines: 5 querqy.solr.SimpleCommonRulesRewriterFactory rules.txt The rules file must be in UTF-8 character encoding. The maximum file size is 1 MB if Solr runs as SolrCloud and if you did not change the maximum file size in ZooKeeper. The file can be gzipped — Querqy will automatically detect and decompress it. Configuration reference: .. code-block:: xml querqy.solr.SimpleCommonRulesRewriterFactory rules.txt true true MULTIPLICATIVE querqy.rewrite.commonrules.WhiteSpaceQuerqyParserFactory rules The rule definitions file. The file is kept in the configset of the collection in ZooKeeper (SolrCloud) or in the 'conf' folder of the Solr core in standalone or master-slave Solr. Can be gzipped (max 1 MB in ZooKeeper). Required. ignoreCase Ignore case in input matching for rules? Default: ``true`` buildTermCache Whether to build a term cache from matching terms. This is an optimisation that might not be feasible for very large rule lists. Default: ``true`` boostMethod How to combine UP/DOWN boosts with the score of the main user query. Available methods are ADDITIVE and MULTIPLICATIVE. Default: ``ADDITIVE`` querqyParser The ``querqy.rewrite.commonrules.QuerqyParserFactory`` to use for parsing strings from the right-hand side of rules into query objects. Default: ``querqy.rewrite.commonrules.WhiteSpaceQuerqyParserFactory`` Rule selection by property ~~~~~~~~~~~~~~~~~~~~~~~~~~ To use rule selection (filtering rules by property), the rewriter must have an ``id`` configured in ``solrconfig.xml``. This id is then referenced in request parameters: .. code-block:: xml common1 querqy.solr.SimpleCommonRulesRewriterFactory rules.txt Rule selection request parameters: .. code-block:: Text querqy.common1.criteria.sort=priority desc querqy.common1.criteria.limit=1 The parameters have the prefix ``querqy..criteria`` where the rewriter ID matches the ``id`` configured in ``solrconfig.xml``. Replace Rewriter ---------------- .. code-block:: xml :linenos: querqy.solr.contrib.ReplaceRewriterFactory replace-rules.txt true ; querqy.rewrite.commonrules.WhiteSpaceQuerqyParserFactory The ``rules`` property references a file in ZooKeeper (SolrCloud) or in the conf directory (standalone) that contains the replace rules. The property ``ignoreCase`` defines whether the rewriter differentiates between upper- and lowercase when matching query terms (default: ``true``). The property ``inputDelimiter`` enables configuring multiple input definitions for the same output, separated by the configured delimiter (default is tab). Word Break Rewriter ------------------- .. code-block:: xml :linenos: querqy.solr.contrib.WordBreakCompoundRewriterFactory f1 true 5 true GERMAN for slipper wissenschaft Number-Unit Rewriter -------------------- .. code-block:: xml :linenos: querqy.solr.contrib.NumberUnitRewriterFactory number-unit-config.json The ``config`` property references a JSON configuration file in ZooKeeper (SolrCloud) or in the conf directory (standalone). Shingle Rewriter ---------------- .. code-block:: xml querqy.solr.contrib.ShingleRewriterFactory false acceptGeneratedTerms If true, also create shingle tokens from terms that were created by other rewriters earlier in the rewrite chain. Default: ``false`` Advanced Configuration ====================== Term Query Cache ---------------- The term query cache avoids building Lucene queries for sub-queries that never match in specific fields. Version-independent cache configuration (``solrconfig.xml``): .. code-block:: xml f1 f2 querqy querqyTermQueryCache true f1 f2 querqy querqyTermQueryCache true Tell the Querqy query parser to use the custom cache: .. code-block:: xml querqyTermQueryCache false The Query String Parser ----------------------- The query string parser defines how the query string passed in request parameter ``q`` is parsed. It can be set using a ``parser`` element in the configuration: .. code-block:: xml querqy.parser.WhiteSpaceQuerqyParser The default ``WhiteSpaceQuerqyParser`` is sufficient for most use cases. Migrating to the Current Version ================================= For detailed information about changes and a migration guide from Querqy 4 to the current version, see :doc:`Migrating to Querqy 5 for Solr `.