<?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>function &#8211; Solr.pl</title>
	<atom:link href="https://solr.pl/en/tag/function-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 20:54:54 +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 4.0: new fl parameter functionalities &#8211; first look</title>
		<link>https://solr.pl/en/2011/11/22/solr-4-0-new-fl-parameter-functionalities-first-look/</link>
					<comments>https://solr.pl/en/2011/11/22/solr-4-0-new-fl-parameter-functionalities-first-look/#respond</comments>
		
		<dc:creator><![CDATA[Rafał Kuć]]></dc:creator>
		<pubDate>Tue, 22 Nov 2011 20:54:35 +0000</pubDate>
				<category><![CDATA[Solr]]></category>
		<category><![CDATA[.0]]></category>
		<category><![CDATA[alias]]></category>
		<category><![CDATA[field]]></category>
		<category><![CDATA[fields]]></category>
		<category><![CDATA[fl]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[pseudo]]></category>
		<category><![CDATA[pseudo fields]]></category>
		<guid isPermaLink="false">http://sematext.solr.pl/?p=382</guid>

					<description><![CDATA[In connection with the work of slowly upcoming release of Apache Solr version 4.0 I thought that it is time to bring some light on the functionalities that you will get into your own hands with the release of Apache]]></description>
										<content:encoded><![CDATA[<p>In connection with the work of slowly upcoming release of Apache Solr version 4.0 I thought that it is time to bring some light on the functionalities that you will get into your own hands with the release of Apache Solr 4.0. The first change we will look at is a simple, but albeit useful functionality called <em>pseudo fields</em>, together with additional features related to the <em>fl</em> parameter.</p>
<p><span id="more-382"></span></p>
<h3>Lets begin</h3>
<p>The Apache Solr 4.0 has changed slightly how <em>fl</em> parameter can be used. In 4.0 this parameters can be added to the query multiple times and Solr will take all the values into consideration. Sometimes it will be useful, at least in my case.</p>
<h3>Custom field names</h3>
<p>In Solr 4.0 you will be able to rename fields that are returned in the results. Imagine that, depending on the query we would like rename fields like <em>price_en</em>, <em>price_pl</em> or <em>price_fr</em> to price. In Solr 4.0, we can do this by placing the following query:
</p>
<pre class="brush:xml">fl=price:price_pl</pre>
<p>This will cause the field <em>price_pl</em> to be returned as <em>price</em>.</p>
<h3>All fields with a common name start</h3>
<p>If we want Solr to return the all fields whose name starts with the word price (useful for dynamic fields) all we will need to do is add the following parameter to the query:
</p>
<pre class="brush:xml">fl=price*</pre>
<h3>Returning function values</h3>
<p>The last functionality, which we will look at today, is the ability add the result of the function, as a field in the documents returned by Solr. Thus, in Solr 4.0 will have the option to add such values as sum of prices, or calculated distance between two points. Quite useful. To use this functionality You will have to add the appropriate function call to the <em>fl</em> parameter for example:
</p>
<pre class="brush:xml">fl=*,stock:sum(stockMain,stockShop)</pre>
<p>The above will result in Solr returning all the fields for the document (value *) and a field named <em>stock</em>, which will be the sum of two fields: <em>stockShop</em> and <em>stockMain</em>.</p>
<h3>A few words at the end</h3>
<p>In addition to the new features mentioned above, there is one more thing that is connected to the parameter <em>fl</em> &#8211; the DocTransformer. However I decided to leave it for a separate blog post.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://solr.pl/en/2011/11/22/solr-4-0-new-fl-parameter-functionalities-first-look/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Sorting by function value in Solr (SOLR-1297)</title>
		<link>https://solr.pl/en/2011/02/28/sorting-by-function-value-in-solr-solr-1297/</link>
					<comments>https://solr.pl/en/2011/02/28/sorting-by-function-value-in-solr-solr-1297/#respond</comments>
		
		<dc:creator><![CDATA[Rafał Kuć]]></dc:creator>
		<pubDate>Mon, 28 Feb 2011 08:17:46 +0000</pubDate>
				<category><![CDATA[Solr]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[function sorting]]></category>
		<category><![CDATA[function value]]></category>
		<category><![CDATA[solr]]></category>
		<category><![CDATA[SOLR-1297]]></category>
		<category><![CDATA[sorting]]></category>
		<category><![CDATA[sorting by function value]]></category>
		<category><![CDATA[value]]></category>
		<guid isPermaLink="false">http://sematext.solr.pl/?p=217</guid>

					<description><![CDATA[In Solr 3.1 and later we have a very interesting functionality, which enables us to sort by function value. What that gives us ? Actually a few interesting possibilities. Let&#8217;s start The first example that comes to mind, perhaps because]]></description>
										<content:encoded><![CDATA[<p>In Solr 3.1 and later we have a very interesting functionality, which enables us to sort by function value. What that gives us ? Actually a few interesting possibilities.</p>
<p><span id="more-217"></span></p>
<h3>Let&#8217;s start</h3>
<p>The  first example that comes to mind, perhaps because of the project on  which I worked some time ago, it&#8217;s sorting on the  basis of distance  between two geographical points. So far, to implement such functionality was needed changes in Solr (for example,  <em>LocalSolr </em>or&nbsp;<em>LocalLucene</em>). Using Solr 3.1 and later, you can sort your search results using the value returned by the defined functions. For example, is Solr, we have the dist function calculating the distance between two points. One variation of the function is a function accepting five parameters: algorithm and two pairs of points. If,  using this feature, we would like to sort your search results in  ascending order from the point of latitude and longitude 0.0, we should  add the following sort parameter to the Solr query:
</p>
<pre class="brush:xml">...sort=dist(2, geo_x, geo_y, 0, 0) asc</pre>
<p>I suspect that the most commonly used values of the first parameter will be:</p>
<ul>
<li><em>1</em> &#8211; calculation based on the Manhattan metrics</li>
<li><em>2</em> &#8211; calculation of Euclidean distance</li>
</ul>
<h3>A few words about performance</h3>
<p>Everything is fine till now, but how it looks like in terms of performance ? I&#8217;ve made a two simple tests.</p>
<p>During  the first test, I indexed 200 000 documents, every one of them  consisted of four fields: identifier (numeric field), description (a<em> text</em> field) and location (two numeric fields). In  order not to obscure the test results for sorting, I used one of the  simplest functions currently available in the Solr &#8211; the <em>sum </em>function which sums two  given arguments. I compared the query time of the default sorting (by <em>score</em>) with the ones which used the value of the function. The following table shows the results of the test:</p>
[table “13” not found /]<br />

<p>Another test was based on a comparison of sorting by a string field to sort using function. The  test was almost identical to the first test. I&#8217;ve indexed 200,000  documents indexed (with additional field: <em>name_sort</em> &#8211; type <em>string</em>) and  used the <em>sum</em> function. The following table shows the results of the test:</p>
[table “15” not found /]<br />

<p>Above test shows that sorting using the sort function is much slower than the default sort order (which you&#8217;d expect). Sorting  on the basis of function value is also slower than sorting with the use  of <em>string </em>based field, but the difference is not as significant as in  the previous case.</p>
<h3>A few words at the end</h3>
<p>Of  course, the above test just glides through the topic of sorting  efficiency using Solr functions, however, shows a direct relationship. Given  that, in most cases, this will not be the default sort method and  giving us a really powerful tool it seems to me that this is a feature  worth remembering. It  will definitely be worth using when the requirements says that we have  to sort on the value that depends on the query and index values &#8211; as in  the case of sorting by distance from the point specified by the user.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://solr.pl/en/2011/02/28/sorting-by-function-value-in-solr-solr-1297/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
