<?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>fq &#8211; Solr.pl</title>
	<atom:link href="https://solr.pl/en/tag/fq/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 22:43:12 +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>Use of cache=false and cost parameters</title>
		<link>https://solr.pl/en/2012/03/05/use-of-cachefalse-and-cost-parameters/</link>
					<comments>https://solr.pl/en/2012/03/05/use-of-cachefalse-and-cost-parameters/#respond</comments>
		
		<dc:creator><![CDATA[Rafał Kuć]]></dc:creator>
		<pubDate>Mon, 05 Mar 2012 22:42:42 +0000</pubDate>
				<category><![CDATA[Solr]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[cache=false]]></category>
		<category><![CDATA[cost]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[fq]]></category>
		<guid isPermaLink="false">http://sematext.solr.pl/?p=445</guid>

					<description><![CDATA[From the day Solr 3.4 was released its users got a nice feature which allows if the results of a filter query or query should be placed in cache. In addition to that we got the possibility to set filter]]></description>
										<content:encoded><![CDATA[<p>From the day <a href="http://solr.pl/en/2011/09/14/lucene-and-solr-3-4/">Solr 3.4</a> was released its users got a nice feature which allows if the results of a filter query or query should be placed in cache. In addition to that we got the possibility to set filter query cost. Let&#8217;s see how to use those features.</p>
<p><span id="more-445"></span></p>
<h3>Parameter cache=false</h3>
<p>Setting the <em>cache</em> parameter to <em>false</em> we tell Solr not to cache current query results. This parameter can also be used as a filter query (<em>fq</em>) attribute, which tell Solr not to cache filter query results. What do we get from such behavior ? Let&#8217;s imagine the following filter as a part of the query:
</p>
<pre class="brush:xml">fq={!frange l=10 u=100}log(sum(sqrt(popularity),100))</pre>
<p>If we know that the queries with filter like the above one are rare, we can decide not to cache them and not change cache state for irrelevant data. To do that we add the <em>cache=false</em> attribute in the following way:
</p>
<pre class="brush:xml">fq={!frange l=10 u=100 cache=false}log(sum(sqrt(popularity),100))</pre>
<p>As I told, adding this additional attribute will result in the filter results not being cached.</p>
<h3>Parameter cost</h3>
<p>The additional feature of Solr 3.4 is the possibility to set filter cost in case of those filters that we don&#8217;t want to cache. Filter queries with specified cost are executed as last ones after all the cached filters. The <em>cost</em> attribute is specified as the integer value. Let&#8217;s look at the following example filters:
</p>
<pre class="brush:xml">fq=cat:video&amp;fq={!cache=false cost=50}productGroup:12&amp;fq={!frange l=10 u=100 cache=false cost=150}log(sum(sqrt(popularity),100))</pre>
<p>The first filter to execute will be the <em>fq=cat:video</em> one because it is cached. The next one to evaluate will be the one with lesser <em>cost</em> value, so the <em>fq={!cache=false cost=50}</em>. The last filter to evaluate will be the most expensive filter. In addition the last filter will operate only on documents that match the main query and all previous filters (because its <em>cost</em> attribute is higher than 100).</p>
<p>You should remember that <em>cost </em>attribute work only when the filter query is not cached.</p>
<h3>To sum up</h3>
<p>With <em>cache </em>and <em>cost</em> attributes we can control what we place in Solr cache, which is very good in most situation, when we know what queries are sent to Solr instances. Whats more, using those attributes we can improve query performance, for those queries that have filters with <em>cost</em> higher than 100. I think it&#8217;s worth to take a while, look at Your queries and think about if You need to cache all of those <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://solr.pl/en/2012/03/05/use-of-cachefalse-and-cost-parameters/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Faceting, filters elimination and how to use it ?</title>
		<link>https://solr.pl/en/2010/12/06/faceting-filters-elimination-and-how-to-use-it/</link>
					<comments>https://solr.pl/en/2010/12/06/faceting-filters-elimination-and-how-to-use-it/#respond</comments>
		
		<dc:creator><![CDATA[Rafał Kuć]]></dc:creator>
		<pubDate>Mon, 06 Dec 2010 22:40:23 +0000</pubDate>
				<category><![CDATA[Solr]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[fq]]></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=160</guid>

					<description><![CDATA[During my everyday work, I have seen many repeated queries, to Solr, with only one filter difference. When I asked why &#8211; I got anserws that it was necessary to get the faceting results for various filters. If you are]]></description>
										<content:encoded><![CDATA[<p>During my everyday work, I have seen many repeated queries, to Solr, with only one filter difference. When I asked why &#8211; I got anserws that it was necessary to get the faceting results for various filters. If  you are using Solr version 1.4 or later, my suggestion is to use<em> local  params</em> &#8211; what is it and how to use &#8211; this post will attempt to answer  both questions.</p>
<p><span id="more-160"></span></p>
<h3>Assumptions</h3>
<p>In order to show how to use the <em>local params</em> with faceting let&#8217;s assume the following situation. In the index we have four fields defined:</p>
<ul>
<li><em>id</em> &#8211; unique identifier,</li>
<li><em>name</em> &#8211; the company name,</li>
<li><em>province </em>&#8211; the province in which the company is located,</li>
<li><em>city</em> &#8211; the city where the company is located.</li>
</ul>
<p>For the simplicity, I assumed that the fields <em>id</em>, <em>province </em>and the <em>city </em>are based on the <em>string </em>type. The field <em>name </em>is a text. Fields are not multivalued and the definition of types is the same as in the standard distribution of Solr.</p>
<h3>Objective</h3>
<p>What we want to achieve ? In addition to finding a company whose name matches the user-entered phrases, the user gives the name of the province and city. User must provide all parameter a simplification to make the example easier to understand. We want to show two types of faceting:</p>
<ul>
<li>cities in which the found companies are, but not narrowed to the selected province,</li>
<li>all provinces in which there are companies that match the query.</li>
</ul>
<h3>Standard approach</h3>
<p>The standard approach would rely on the generation of two queries:
</p>
<pre class="brush:xml">q=PHRASE&amp;fq=city:CITY&amp;province:PROVINCE</pre>
<pre class="brush:xml">q=PHRASE&amp;facet=true&amp;facet.field=city&amp;facet.field=province</pre>
<p>The first is responsible for the collection of companies that match the phrase entered and are narrowed to the city and province, while the second gives us the desired faceting without refinements.</p>
<h3>Local params</h3>
<p>Solr 1.4 brought an interesting feature &#8211; <em>local params</em>. In our case, what counts is that the tagging feature allows you to filter and eliminate the filters in faceting mechanism. These two queries can be replaced as follows:
</p>
<pre class="brush:xml">q=PHRASE&amp;fq={!tag=tagCity}city:CITY&amp;fq={!tag=tagProvince}province:PROVINCE&amp;facet=true&amp;facet.field={!ex=tagCity,tagProvince}city&amp;facet.field=!{ex=tagCity,tagProvince}province</pre>
<h3>How does it work ?</h3>
<p>First of all, for each filter (the <em>fq</em> parameter) we define a unique tag by which we can refer to the filter. To do this we use the following structure<em> {!tag=TAG_NAME}</em>.</p>
<p>Then for each of the fields we want to use to do faceting we add information which filters should be excluded. In our case, we exclude the two filters in both fields when using faceting. To do this we use the following structure <em>{!ex = TAG_NAME_1, TAG_NAME_2 ,&#8230;}</em>.</p>
<h3>A few words at the end</h3>
<p>Of course, the functionality of <em>local params</em> is not only the faceting and the possibility of filter exclusion. I promise that in the future there will be another entry describing the wider opportunities offered by Solr and the local params functionality introduced in version 1.4.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://solr.pl/en/2010/12/06/faceting-filters-elimination-and-how-to-use-it/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
