<?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>local params &#8211; Solr.pl</title>
	<atom:link href="https://solr.pl/en/tag/local-params-2/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>
		<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>
		<item>
		<title>The scope of Solr faceting</title>
		<link>https://solr.pl/en/2010/08/23/the-scope-of-solr-faceting/</link>
					<comments>https://solr.pl/en/2010/08/23/the-scope-of-solr-faceting/#respond</comments>
		
		<dc:creator><![CDATA[Rafał Kuć]]></dc:creator>
		<pubDate>Mon, 23 Aug 2010 12:07:58 +0000</pubDate>
				<category><![CDATA[Solr]]></category>
		<category><![CDATA[date faceting]]></category>
		<category><![CDATA[facet]]></category>
		<category><![CDATA[facet method]]></category>
		<category><![CDATA[facet parameter]]></category>
		<category><![CDATA[facet query]]></category>
		<category><![CDATA[faceting]]></category>
		<category><![CDATA[local]]></category>
		<category><![CDATA[local params]]></category>
		<category><![CDATA[params]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[range faceting]]></category>
		<category><![CDATA[solr]]></category>
		<guid isPermaLink="false">http://sematext.solr.pl/?p=69</guid>

					<description><![CDATA[Faceting is one of the ways to categorize the content found in the process of information retrieval. In case of Solr this is the division of set of documents on the basis of certain criteria: content of individual fields, queries]]></description>
										<content:encoded><![CDATA[<p>Faceting is one of the ways to categorize the content found in the  process of information retrieval. In case of Solr this is the division  of set of documents on the basis of certain criteria: content of  individual fields, queries or on the basis of compartments or dates. In  today&#8217;s entry I will try to some scope on the possibility of using the  faceting mechanism, both currently available in Solr 1.4.1, as well as  what will be available in the future.</p>
<p><span id="more-69"></span></p>
<p>One of the few sources of information about faceting is Solr wiki &#8211;  to be more specific &#8211; the page at:  <a href="http://wiki.apache.org/solr/SimpleFacetParameters" target="_blank" rel="noopener noreferrer">http://wiki.apache.org/solr/SimpleFacetParameters</a>. The following article  is an extension to the information available on the wiki website.</p>
<p>Solr faceting mechanism can be divided into four basic types:</p>
<ul>
<li>field faceting,</li>
<li>query faceting,</li>
<li>date faceting,</li>
<li>range facteing.</li>
</ul>
<p>To turn Solr faceting mechanism on, one need to pass <em>facet</em> parameter with the value <em>true</em>.</p>
<h3>Field faceting</h3>
<p>First type of faceting. This type of faceting categorize documents  found due to specified field. With this type of faceting we are able to  get a number of documents found for example in each category or  geographical location. Faceting by field is characterized by a large  number of options which configure its behavior. This are the parameters  available for use:</p>
<ul>
<li><em>facet.field</em> &#8211; parameter specifying which field will be  used to perform faceting. This parameter can be specified multiple  times. Remember that adding multiple <em>facet.field</em> parameters to the query can affect performance.</li>
<li><em>facet.prefix</em> &#8211; restricts faceting results to those that begin with the specified  prefix. The parameter can be defined for each field specified by the <em>facet.field</em> parameter &#8211; you can do it, by adding a parameter like this: <em>facet.field_name.prefix</em>. This parameter is a relatively simple way to implement autocomplete mechanism.</li>
<li><em>facet.sort</em> &#8211; specifies how to sort faceting results. If You use Solr version lower than 1.4, this parameter takes values of <em>true </em>or <em>false</em> indicating successively &#8211; sort by the number of results and sort by  index order (in the case of ASCII this means alphabetical sorting). If  however You are using Solr version 1.4 or higher You should use <em>count</em> value (meaning the same as <em>true</em>), or <em>index</em> value (meaning the same as <em>false</em>). The default value for this parameter is <em>true/count</em> when <em>facet.limit</em> set to 0 or <em>false/index</em> for other values of <em>facet.limit</em> parameter. The parameter can be defined for each field specified by the <em>facet.field</em> parameter.</li>
<li><em>facet.limit</em> &#8211; parameter specifying how many unique values of faceting results to  display. A negative value for this parameter mean no limit. Please note  that the larger the limit, the more memory you need and the longer query  execution. Default parameter value is 100. The parameter can be defined  for each field specified by the <em>facet.field</em> parameter.</li>
<li><em>facet.offset</em> &#8211; parameter defining from offset (from the first faceting result) of  presented faceting results. Default parameter value is 0. This parameter  is designed to help implementing faceting result paging. The parameter  can be defined for each field specified by the <em>facet.field</em> parameter.</li>
<li><em>facet.mincount</em> &#8211; parameter specifying the minimum size of result to be included in  faceting results. The default value is 0. The parameter can be defined  for each field specified by the <em>facet.field</em> parameter.</li>
<li><em>facet.missing</em> &#8211; parameter specifying whether, in addition to standard faceting  results, number of documents without a value in the specified field  should be included. This parameter can take values of <em>true</em> or <em>false</em>. The default parameter value is <em>false</em>. The parameter can be defined for each field specified by the <em>facet.field</em> parameter.</li>
<li><em>facet.method &#8211; </em>parameter introduced in Solr 1.4. It takes the value of <em>enum</em> or <em>fc</em>. Specifies a method for faceting calculation. Setting this parameter to <em>enum</em> effects in using term enumeration to calculate faceting results. This  method is proven to be most efficient when dealing with fields with  small number of unique terms. The second method, labeled <em>fc</em>, is  the standard method for faceting calculation. It takes all the results  and iterate over all documents in the result set. The parameter can be  defined for each field specified by the <em>facet.field</em> parameter. The default value is <em>fc</em> for all the fields not based on <em>Boolean</em> type.</li>
<li><em>facet.enum.cache.minDf</em> &#8211; parameter with strange sounding name specifying the minimum number of matching documents to a single term to the <em>fc </em>method to be used for faceting result calculation. I know it sounds strange but i do not know how to explain it easier <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f609.png" alt="😉" class="wp-smiley" style="height: 1em; max-height: 1em;" /></li>
</ul>
<p>These are the parameters of field faceting. In case of most  parameters I have written that there is a possibility to define their  values for each field specified by <em>facet.field</em> parameter. How does it look like ? Suppose we have a query like this:
</p>
<pre class="brush:xml">q=solr&amp;facet=true&amp;facet.field=category&amp;facet.field=location</pre>
<p>It is a simple query for &#8216;solr&#8217; term with faceting mechanism turned on. There are two facet fields defined &#8211; <em>category</em> and <em>location</em>. Lets say, that we would like to have 200 facet results for <em>category </em>field sorted by count and 50 facet results for <em>location</em> field sorted alphabetically. To do that we add the following fragment to the query shown above:
</p>
<pre class="brush:xml">facet.category.limit=200&amp;facet.category.sort=count&amp;facet.location.limit=50&amp;facet.location.sort=index</pre>
<p>As shown we can easily modify facet mechanism behavior for individual facet fields.</p>
<h3>Query faceting</h3>
<p>Facet mechanism based on a single parameter &#8211; <em>facet.query</em> to  which we give a query. The query passed to the parameter must be  constructed so that standard Lucene query parser can understand it. An example use of this parameter is, for example query a group of pricing, which could look like:
</p>
<pre class="brush:xml">facet.query=price: [0+TO+100]</pre>
<p>Note,  however, that each added <em>facet.query</em> parameter is another  query to Lucene, which means performance loss. Many <em>facet.query</em> parameters in a query can be painful to Solr.</p>
<p>There is one more thing worth mentioning when  talking about query faceting &#8211; there is a possibility to define your own  parser to parse <em>facet.query</em> parameter value. To use your own parser, for example, called <em>myParser</em> parameter passed to Solr should look like this:
</p>
<pre class="brush:xml">facet.query={!myParser}aaa</pre>
<h3>Date faceting</h3>
<p>New faceting functionality introduced in Solr 1.3. Date faceting allows you to calculate faceting results including all the intricacies of processing dates. Please note that date faceting can only be used with fields based on the type <em>solr.</em><em>DateField</em>. Now let&#8217;s get on with the parameters associated with date faceting:</p>
<ul>
<li><em> facet.date</em> &#8211; like <em>facet.field</em> parameter, this parameter is used to identify fields where dates faceting should be used. As  in the case of <em>facet.field</em> parameter you can specify this parameter  several times to allow date faceting on many fields in one  query.</li>
<li><em>facet.date.start &#8211; </em>parameter  specifying the lower limit of date on which the faceting calculation  should be started. This parameter can be defined for each field  specified by the <em>facet.date </em>parameter. This parameter is mandatory when using <em>facet.date</em> and should be defined for each <em>facet.date</em> parameter.</li>
<li><em>facet.date.end</em> &#8211; parameter defining the upper limit of the date, on which the faceting  calculation should be ended. This parameter can be defined for each  field specified by the <em>facet.date </em>parameter. This parameter is mandatory when using <em>facet.date </em>and should be defined for each <em>facet.date</em> parameter.</li>
<li><em>facet.date.gap</em> &#8211; parameter specifying date compartments to be generated for the defined boundaries. This parameter is mandatory when using <em>facet.date</em> and should be defined for each <em>facet.date</em> parameter. The parameter can be defined for each field specified by the <em>facet.date </em>parameter.</li>
<li><em>facet.date.hardend</em> &#8211; parameter taking values <em> true </em>and <em>false</em>, telling Solr what to do in the case when the parameter <em>facet.date.gap</em> is not evenly splitting the compartments. If we set this parameter to <em>true</em> the last compartment generated by <em>facet.date.gap</em> parameter can be wider than the boundary defined by <em>facet.date.end</em> parameter. If we set this parameter to <em>false</em> (default value) the last compartment generated by <em>facet.date.gap</em> parameter can be smaller then the rest of the ranges. The parameter can be defined for each field specified by the <em>facet.date </em>parameter.</li>
<li><em>facet.date.other</em> &#8211; parameter specifying what values besides the standard ones (ranges)  should be added to results of date faceting. The parameter can be  defined for each field specified by the <em>facet.date </em>parameter. The parameter can take following values:
<ul>
<li><em>before </em>&#8211; in addition to the standard date faceting  results, there will be one more &#8211; number of documents with a date before  the one defined in the <em>facet.date.start</em> parameter,</li>
<li><em>after</em> &#8211; in addition to the standard date faceting results, there will be one  more &#8211; number of documents with the date after the one defined in the <em>facet.date.end</em> parameter,</li>
<li><em>between </em>&#8211; in addition to the standard date faceting results, there will be one more &#8211; number of documents with the date between <em>facet.date.start</em> and <em>facet.date.end</em> parameters,</li>
<li><em>all</em> &#8211; a shortcut to define all the above,</li>
<li><em>none </em>&#8211; none of the additional results will be added to date faceting results.</li>
</ul>
</li>
<li><em>facet.date.include</em> &#8211; parameter that will be introduced  in Solr 4.0. It allows of closing or opening of the compartments  defined by the boundaries and the gap. The parameter will accept the  following values:
<ul>
<li><em>lower</em> &#8211; each of the resulting compartment will contain its lower limit,</li>
<li><em>upper</em> &#8211; each of the resulting compartment will contain its upper limit,</li>
<li><em>egde</em> &#8211; the first and last interval will include its external borders &#8211; that  is, for the first lower and upper range for the last interval,</li>
<li><em>outer</em> &#8211; a parameter specifying that the compartments defined by the values <em>before</em> and <em>after</em> of the <em>facet.date.other</em> parameter will contain its borders, even if other compartments already contain these borders,</li>
<li><em>all</em> &#8211; a parameter that causes the inclusion of all of the above options.</li>
</ul>
</li>
</ul>
<p>That is how we can modify the behavior of the date faceting. Now, some example of using this kind of faceting:
</p>
<pre class="brush:xml">q=solr&amp;facet=true&amp;facet.date=addDate&amp;facet.date.start=NOW/DAY-30DAYS&amp;facet.date.end=NOW/DAY%2B30DAYS&amp;facet.date.gap=%2B1DAY</pre>
<p>What does the above query do ? We turn the faceting mechanism on, we define date faceting for <em>addDate</em> field. What we want to get is the compartments between 30 days before today (<em>NOW/DAY-30DAYS</em>) and 30 days after today (<em>NOW/DAY+30DAYS)</em>. The compartments will be of the size of a single day.</p>
<h3>Range faceting</h3>
<p>Functionality which will be available in Solr 3.1. If someone want to test it right now, both the trunk and branch 3.x have this  functionality implemented. This method of faceting is the extension of  date faceting. This functionality works similar to date faceting &#8211; as a  result we get a list of compartments constructed automatically based on  parameters. Here are the list of parameters that can be used to define  range faceting behavior:</p>
<ul>
<li><em> facet.range </em>&#8211; like <em>facet.field</em> parameter, this parameter is used to identify fields where range faceting should be used. As  in the case of <em>facet.field</em> parameter you can specify this parameter  several times to allow range faceting on many fields in one  query.</li>
<li><em>facet.range.start &#8211; </em>parameter   specifying the lower limit of range on which the faceting calculation   should be started. This parameter can be defined for each field  specified  by the <em>facet.range </em>parameter. This parameter is mandatory when using <em>facet.range </em>and should be defined<em> </em>for each <em>facet.range</em> parameter.</li>
<li><em>facet.range.end</em> &#8211; parameter defining the upper limit of the range, on which the  faceting  calculation should be ended. This parameter can be defined for  each field specified  by the <em>facet.range </em>parameter. This parameter is mandatory when using <em>facet.range </em>and should be defined<em> </em>for each <em>facet.range</em> parameter.</li>
<li><em>facet.range.gap</em> &#8211; parameter specifying range compartments to be generated for the defined boundaries. This parameter is mandatory when using <em>facet.range</em> and should be defined for each <em>facet.date</em> parameter. The parameter can be defined for each field specified by the <em>facet.date </em>parameter.</li>
<li><em>facet.range.hardend</em> &#8211; parameter taking values <em> true </em>and <em>false</em>, telling Solr what to do in the case when the parameter <em>facet.range.gap</em> is not evenly splitting the compartments. If we set this parameter to <em>true</em> the last compartment generated by <em>facet.range.gap</em> parameter can be wider than the boundary defined by <em>facet.range.end</em> parameter. If we set this parameter to <em>false</em> (default value) the last compartment generated by <em>facet.range.gap</em> parameter can be smaller then the rest of the ranges. The parameter can be defined for each field specified by the <em>facet.range</em>parameter.</li>
<li><em>facet.range.other</em> &#8211; parameter specifying what values besides the standard ones (ranges)   should be added to results of range faceting. The parameter can be   defined for each field specified by the <em>facet.range </em>parameter. The parameter can take following values:
<ul>
<li><em>before </em>&#8211;  in addition to the standard range faceting  results, there will be one  more &#8211; number of documents with a values  lower than the one defined in the <em>facet.range.start</em> parameter,</li>
<li><em>after</em> &#8211; in addition to the standard range faceting results, there will be one   more &#8211; number of documents with the values higher than the one defined  in the <em>facet.range.end</em> parameter,</li>
<li><em>between </em>&#8211; in addition to the standard range faceting results, there will be one more &#8211; number of documents with the values between <em>facet.range.start</em> and <em>facet.range.end</em> parameters,</li>
<li><em>all</em> &#8211; a shortcut to define all the above,</li>
<li><em>none </em>&#8211; none of the additional results will be added to range faceting results.</li>
</ul>
</li>
<li><em>facet.range.include</em> &#8211; parameter allowing closing  or  opening of the compartments defined by the boundaries and the gap.  The  parameter will accept the following values:
<ul>
<li><em>lower</em> &#8211; each of the resulting compartment will contain its lower limit,</li>
<li><em>upper</em> &#8211; each of the resulting compartment will contain its upper limit,</li>
<li><em>egde</em> &#8211; the first and last interval will include its external borders &#8211; that   is, for the first lower and upper range for the last interval,</li>
<li><em>outer</em> &#8211; a parameter specifying that the compartments defined by the values <em>before</em> and <em>after</em> of the <em>facet.range.other</em> parameter will contain its borders, even if other compartments already contain these borders,</li>
<li><em>all</em> &#8211; a parameter that causes the inclusion of all of the above options.</li>
</ul>
</li>
</ul>
<p>As you can see the range faceting parameters are almost identical to  those in date faceting. The behavior is also almost identical. An  example query using ranges faceting may be the following query:
</p>
<pre class="brush:xml">q=solr&amp;facet=true&amp;facet.range=price&amp;facet.range.start=0&amp;facet.range.end=1000&amp;facet.range.gap=100</pre>
<p>So, we went through all of the types of faceting. But thats not all.  Users of Solr version 1.4 and higher have the opportunity to use the  so-called LocalParams.</p>
<h3>LocalParams and faceting</h3>
<p>Suppose we have a requirement.﻿ We  have a query that returns search results for the term &#8216;solr&#8217; and in  which we have defined two filters, one for category and one for the  country of origin of the document. In addition to the search results we  want to enable navigation through the regions and categories, but we  would like them not to be dependend on each other. That is, we want to  give the opportunity to navigate through the regions for the term &#8216;solr&#8217;  but we dont want it to be limited to the selected category, and vice  versa. To do it in Solr version 1.3 or earlier, we would write the  following query:
</p>
<pre class="brush:xml">q=solr&amp;fq=category:search&amp;fq=region:poland
q=solr&amp;facet=true&amp;facet.field=category&amp;facet.field=region</pre>
<p>Two  queries, because first we have to get narrowed search results, on the  other hand we need the faceting result not to be narrowed by filters.  For Solr version 1.4 or higher, we can shorten this to one query. For  this purpose, we use the possibility of tagging and exclusion of tagged  parameters. First we change the query as follows:
</p>
<pre class="brush:xml">q=solr&amp;fq={!tag=categoryFQ}fq=category:search&amp;fq={!tag=regionFQ}region:poland</pre>
<p>For  now, the search results will not change. We added tags to the filters  in the above query so we can later exclude them in faceting. Then we  modify the second query as follows:
</p>
<pre class="brush:xml">q=solr&amp;facet=true&amp;facet.field={!ex=categoryFQ,regionFQ}category&amp;facet.field={!ex=categoryFQ,regionFQ}region</pre>
<p>So far the faceting results will not change. We added exclusions to the <em>facet.field</em> parameters, so filters named <em>categoryFQ</em> and <em>regionFQ</em> will not be taken into consideration when calculating faceting results.</p>
<p>Then we combine the modified query, so it should look as follows:
</p>
<pre class="brush:xml">q=solr&amp;fq={!tag=categoryFQ}fq=category:search&amp;fq={!tag=regionFQ}region:poland&amp;facet=true&amp;facet.field={!ex=categoryFQ,regionFQ}category&amp;facet.field={!ex=categoryFQ,regionFQ}region</pre>
<p>I`ll write more about LocalParams in a future entries.</p>
<h3>A few words at the end</h3>
<p>I  hope that this article approached the possibility of using Solr  faceting, both in earlier versions of Solr, in the present, as well as  those that arise in the nearest future.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://solr.pl/en/2010/08/23/the-scope-of-solr-faceting/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
