<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>1.4 &#8211; Solr.pl</title>
	<atom:link href="https://solr.pl/en/tag/1-4/feed/" rel="self" type="application/rss+xml" />
	<link>https://solr.pl/en/</link>
	<description>All things to be found - Blog related to Apache Solr &#38; Lucene projects - https://solr.apache.org</description>
	<lastBuildDate>Wed, 11 Nov 2020 08:21:20 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9</generator>
	<item>
		<title>Solr 1.4: Local Params</title>
		<link>https://solr.pl/en/2011/03/28/solr-1-4-local-params/</link>
					<comments>https://solr.pl/en/2011/03/28/solr-1-4-local-params/#respond</comments>
		
		<dc:creator><![CDATA[Rafał Kuć]]></dc:creator>
		<pubDate>Mon, 28 Mar 2011 07:20:29 +0000</pubDate>
				<category><![CDATA[Solr]]></category>
		<category><![CDATA[1.4]]></category>
		<category><![CDATA[faceting]]></category>
		<category><![CDATA[local]]></category>
		<category><![CDATA[local params]]></category>
		<category><![CDATA[params]]></category>
		<category><![CDATA[solr]]></category>
		<guid isPermaLink="false">http://sematext.solr.pl/?p=225</guid>

					<description><![CDATA[Several months ago, during one of the projects I have tried to construct a query with optimal faceting. The problem was that we need filters (fq) in the query but in the same time we need a faceting that was]]></description>
										<content:encoded><![CDATA[<p>Several months ago, during one of the projects I have tried to construct a query with optimal faceting.  The problem was that we need filters (<em>fq</em>) in the query but in the same time we need a faceting that was not filtered. To some point it was not possible in Solr &#8211; you had to make two queries.  But now, you can do it with one query. Let&#8217;s meet <em>LocalParams</em>.</p>
<p><span id="more-225"></span></p>
<h3>The begining</h3>
<p><em>LocalParams </em>lets you tag part of the query, for example:
</p>
<pre class="brush:xml">q=*:*&amp;fq={!tag=city}city:warszawa</pre>
<p>After  sending the above query to Solr it will remember (in the context of the  same query) that tag named <em>city </em>covers the filter with a value of <em>city: warszawa</em>. Now  suppose that we want to send a query to get all documents that have the <em>warszawa</em> value in the <em>city</em> field (lets suppose that the <em>city </em>field is  multi valued). In addition, we want to Solr to show us the number of documents in all cities. Nothing could be simpler with the use of <em>LocalParams </em>&#8211; just use the parameter <em>{!ex}</em> in the faceting. This could possibly be done by sending the following query to Solr:
</p>
<pre class="brush:xml">q=*:*&amp;fq={!tag=miasto}city:warszawa&amp;facet=true&amp;facet.field={!ex=miasto}city</pre>
<p>The  above query will return documents that have the <em>warszawa </em>value in the <em> city </em>field and faceting calculated on the <em>city </em>field which is not  narowed by the filter query, because we excluded that filter.</p>
<h3>Query parser type</h3>
<p>Of course, the use of <em>LocalParams </em>is not limited to faceting. One of the interesting examples is a type handler definition. If we use <em>standard</em> query parser, we can change its type for a particular query with this structure:
</p>
<pre class="brush:xml">q={!type=dismax qf=city}warszawa</pre>
<p>The  above query will use the <em>dismax </em>query parser and pass the <em>qf=city</em> parameter to it along with the <em>warszawa</em> value in the <em>q</em> parameter.</p>
<h3>Logical operator</h3>
<p>Changing the default logical operator using <em>LocalParams </em>is also very simple:
</p>
<pre class="brush:xml">q={!q.op=AND}warszawa praga</pre>
<p>The above query uses the AND logical operator for terms contained in the parameter <em>q</em>, which are <em>warszawa</em> and <em>praga</em>.</p>
<h3>Parameter dereferencing</h3>
<p>Additionally, by using <em>LocalParams </em>we can achieve an interesting feature &#8211; the parameters dereferencing. For example, if we want to use your own parameter names in queries, we can do it this way:
</p>
<pre class="brush:xml">q={!type=dismax qf=city v=$pmiasto}&amp;pmiasto=warszawa</pre>
<p>Solr  does not support default parameter named <em>pmiasto</em>, but with the key <em>v</em> (meaning value) and use of the reference operator <em>$</em> it was possible to  transfer the value of such a named parameter to the query.</p>
<p>I recommend that everyone who wants to use this feature in your application to play with <em>LocalParams </em>and find out if they fit your needs.</p>
<h3>More information</h3>
<p>Actual information about <em>LocalParams</em> and Solr can be found at Apache Solr wiki at the following address: <a href="http://wiki.apache.org/solr/LocalParams" target="_blank" rel="noopener noreferrer">http://wiki.apache.org/solr/LocalParams</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://solr.pl/en/2011/03/28/solr-1-4-local-params/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
