Return-Path: Delivered-To: apmail-lucene-solr-commits-archive@minotaur.apache.org Received: (qmail 61438 invoked from network); 23 Sep 2009 21:55:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 23 Sep 2009 21:55:06 -0000 Received: (qmail 3889 invoked by uid 500); 23 Sep 2009 21:55:06 -0000 Delivered-To: apmail-lucene-solr-commits-archive@lucene.apache.org Received: (qmail 3812 invoked by uid 500); 23 Sep 2009 21:55:05 -0000 Mailing-List: contact solr-commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: solr-dev@lucene.apache.org Delivered-To: mailing list solr-commits@lucene.apache.org Received: (qmail 3798 invoked by uid 99); 23 Sep 2009 21:55:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Sep 2009 21:55:05 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.130] (HELO eos.apache.org) (140.211.11.130) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Sep 2009 21:55:03 +0000 Received: from eos.apache.org (localhost [127.0.0.1]) by eos.apache.org (Postfix) with ESMTP id 7BEBA11154 for ; Wed, 23 Sep 2009 21:54:43 +0000 (GMT) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Apache Wiki To: Apache Wiki Date: Wed, 23 Sep 2009 21:54:43 -0000 Message-ID: <20090923215443.3276.53324@eos.apache.org> Subject: =?utf-8?q?=5BSolr_Wiki=5D_Update_of_=22LocalParams=22_by_naomidushay?= X-Virus-Checked: Checked by ClamAV on apache.org Dear Wiki user, You have subscribed to a wiki page or wiki category on "Solr Wiki" for chan= ge notification. The "LocalParams" page has been changed by naomidushay: http://wiki.apache.org/solr/LocalParams?action=3Ddiff&rev1=3D6&rev2=3D7 =3D LocalParams =3D - LocalParams stands for local parameters... arguments in a Solr request th= at are localized and specific to a parameter. They provide a way to add me= ta-data to certain argument types such as query strings. + LocalParams stands for local parameters: they provide a way to "localize= " information about a specific argument that is being sent to Solr. In oth= er words, LocalParams provide a way to add meta-data to certain argument ty= pes such as query strings. = - If localparams exist as prefixes to arguments. + LocalParams are expressed as prefixes to arguments to be sent to Solr. F= or example: + = - Assuming we have the existing query parameter + Assume we have the existing query parameter - {{{q=3Dsolr rocks + `q=3Dsolr rocks` - }}} - We can prefix this query string with localparams to provide more informat= ion to the query parser, for example changing the default operator type to = "AND" and the default field to "title" for the lucene query parser. + We can prefix this query string with LocalParams to provide more informat= ion to the query parser, for example changing the default operator type to = "AND" and the default field to "title" for the lucene query parser: - {{{q=3D{!q.op=3DAND df=3Dtitle}solr rocks + `q=3D{!q.op=3DAND df=3Dtitle}solr rocks` - }}} = =3D=3D=3D Basic Syntax =3D=3D=3D - An argument with localparams starts with {{{ {! }}}, includes any number = of {{{key=3Dvalue}}} pairs separated by whitespace, and the localparams end= with {{{ } }}} followed by the original argument value. There may only be= one localparams prefix per argument, preventing the need for any escaping = of the original argument. Values in the key-value pairs may be quoted via = single or double quotes, and backslash escaping works within quoted strings. + To indicate a LocalParam, the argument is prefixed with curly braces whos= e contents begin with an exclamation point and include any number of `key= =3Dvalue` pairs separated by whitespace. So if the original argument is `f= oo`, applying LocalParams would look something like `{!k1=3Dv1 k2=3Dv2 k3= =3Dv3}foo`. + = + There may only be one LocalParams prefix per argument, preventing the nee= d for any escaping of the original argument. Values in the key-value pairs= may be quoted via single or double quotes, and backslash escaping works wi= thin quoted strings. + = + `q=3D{!type=3Ddismax qf=3D'myfield yourfield'}solr rocks` = + is equivalent to = + `q=3D{!type=3Ddismax qf=3D"myfield yourfield"}solr rocks` + but = + `q=3D{!type=3Ddismax qf=3Dmyfield yourfield}solr rocks` + will give an error because "yourfield" is expected to be a key=3Dvalue pa= ir. + = + example of backslash escaping: + `q=3D{!type=3Ddismax qf=3D"title"}2 \+ 2` = =3D=3D=3D Query type short-form =3D=3D=3D - If a localparam value appears without a name, it is given the implicit na= me of "type". This allows short-form representation for the type of query = parser to use when parsing a query string. Thus = + If a LocalParams value appears without a name, it is given the implicit n= ame of "type". This allows short-form representation for the type of query= parser to use when parsing a query string. Thus = - {{{q=3D{!dismax qf=3Dmyfield}solr rocks + `q=3D{!dismax qf=3Dmyfield}solr rocks` - }}} is equivalent to = + is equivalent to = - {{{q=3D{!type=3Ddismax qf=3Dmyfield}solr rocks + `q=3D{!type=3Ddismax qf=3Dmyfield}solr rocks` - }}} = =3D=3D=3D Parameter value =3D=3D=3D A special key of "v" within local parameters is an alternate way to speci= fy the value of that parameter. - {{{q=3D{!dismax qf=3Dmyfield}solr rocks + `q=3D{!dismax qf=3Dmyfield}solr rocks` - }}} is equivalent to = + is equivalent to = - {{{q=3D{!type=3Ddismax qf=3Dmyfield v=3D'solr rocks'} + `q=3D{!type=3Ddismax qf=3Dmyfield v=3D'solr rocks'}` - }}} = =3D=3D=3D Parameter dereferencing =3D=3D=3D Parameter dereferencing or indirection allows one to use the value of ano= ther argument rather than specifying it directly. This can be used to simp= lify queries, decouple user input from query parameters, or decouple front-= end GUI parameters from defaults set in solrconfig.xml. - {{{q=3D{!dismax qf=3Dmyfield}solr rocks + `q=3D{!dismax qf=3Dmyfield}solr rocks` - }}} is equivalent to = + is equivalent to = - {{{q=3D{!type=3Ddismax qf=3Dmyfield v=3D$qq}&qq=3Dsolr rocks + `q=3D{!type=3Ddismax qf=3Dmyfield v=3D$qq}&qq=3Dsolr rocks` - }}} =20