<?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>Intelligrape  Groovy &#38; Grails Blogs &#187; plugin</title>
	<atom:link href="http://www.intelligrape.com/blog/tag/plugin/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.intelligrape.com/blog</link>
	<description></description>
	<lastBuildDate>Thu, 02 Feb 2012 07:48:06 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<image>
			<title>Intelligrape  Groovy &amp; Grails Blogs</title>
			<url>http://www.intelligrape.com/blog/wp-content/uploads/2011/05/favicon2.ico</url>
			<link>http://www.intelligrape.com/blog</link>
			<width></width>
			<height></height>
			<description></description>
		</image>		<item>
		<title>Searchable plugin &#8211; Lucene search on numeric values</title>
		<link>http://www.intelligrape.com/blog/2010/07/14/searchable-plugin-lucene-search-on-numeric-values/</link>
		<comments>http://www.intelligrape.com/blog/2010/07/14/searchable-plugin-lucene-search-on-numeric-values/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 18:15:47 +0000</pubDate>
		<dc:creator>Aman Aggarwal</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[long]]></category>
		<category><![CDATA[lucene]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[numbertools]]></category>
		<category><![CDATA[numeric]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[searchable]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=1274</guid>
		<description><![CDATA[While using searchable plugin for the first time, I wasn&#8217;t aware that lucene implements only lexicographic comparisons for searching on indexed values (even on numeric fields). Before I learned this, I kept on wondering why a Person of age 6 always appeared in search results when I look for People more than 20 years of [...]]]></description>
			<content:encoded><![CDATA[<p>While using searchable plugin for the first time, I wasn&#8217;t aware that lucene implements only lexicographic comparisons for searching on indexed values (even on numeric fields). Before I learned this, I kept on wondering why a Person of age 6 always appeared in search results when I look for People more than 20 years of age. The solution was to define a transient field ageIndexValue in domain class Person and implement its getter as:</p>

<div class="wp_syntax"><div class="code"><pre class="groovy"><span style="color: #aaaadd; font-weight: bold;">String</span> getAgeIndexValue<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> org.<span style="color: #006600;">apache</span>.<span style="color: #006600;">lucene</span>.<span style="color: #006600;">document</span>.<span style="color: #006600;">NumberTools</span>.<span style="color: #006600;">NumberTools</span>.<span style="color: #006600;">longToString</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">age</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Also, you will need to change the search query from</p>

<div class="wp_syntax"><div class="code"><pre class="groovy">q<span style="color: #66cc66;">=</span>age:<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">20</span> TO <span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#93;</span> to q<span style="color: #66cc66;">=</span>ageIndexValue:<span style="color: #66cc66;">&#91;</span>0000000000000u TO <span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#93;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="groovy">where, 0000000000000u <span style="color: #66cc66;">==</span> org.<span style="color: #006600;">apache</span>.<span style="color: #006600;">lucene</span>.<span style="color: #006600;">document</span>.<span style="color: #006600;">NumberTools</span>.<span style="color: #006600;">longToString</span><span style="color: #66cc66;">&#40;</span>20L<span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>~Aman Aggarwal<br />
<a href="mailto:aman@intelligrape.com">aman@intelligrape.com</a></p>
<p><a href="http://www.IntelliGrape.com/">http://www.IntelliGrape.com/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2010/07/14/searchable-plugin-lucene-search-on-numeric-values/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Configuring multiple senders in Grails Mail plugin</title>
		<link>http://www.intelligrape.com/blog/2010/06/14/configuring-multiple-senders-in-grails-mail-plugin/</link>
		<comments>http://www.intelligrape.com/blog/2010/06/14/configuring-multiple-senders-in-grails-mail-plugin/#comments</comments>
		<pubDate>Mon, 14 Jun 2010 06:21:58 +0000</pubDate>
		<dc:creator>Abhishek Tejpaul</dc:creator>
				<category><![CDATA[Grails]]></category>
		<category><![CDATA[Java tools]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[multiple senders]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://www.intelligrape.com/blog/?p=1050</guid>
		<description><![CDATA[In one of the recent projects, we had to set up a system where emails for different purposes (i.e registration, error reporting etc.) were to be sent out from different email accounts. We were using the Grails Mail plugin which does not provide a clear way to set-up or configure multiple email addresses. With the [...]]]></description>
			<content:encoded><![CDATA[<p>In one of the recent projects, we had to set up a system where emails for different purposes (i.e registration, error reporting etc.) were to be sent out from different email accounts. We were using the Grails Mail plugin which does not provide a clear way to set-up or configure multiple email addresses. With the help of my colleague, <strong>Chandan Luthra</strong>, I tried to dig into the workings of plugin and found out that Mail plugin injects the properties such as username, password etc. through a bean named mailSender. So we just did the following to customize/configure these properties on the fly from the controller or a service:</p>
<pre>CH.config.grails.mail.default.from = "username@domain.com" // Mail plugin uses this to connect to the account in e-mail provider's server. So it should be set.
mailSender.username = "username@domain.com"
mailSender.password = "sample123!"</pre>
<p>And yes, once you are done with your email sending functionality you can set mailSender properties back to the default settings set originally in Config.groovy. Your service/controller code could look something like this:</p>
<pre>// Store the default mail settings in variables
def defaultFrom = CH.config.grails.mail.default.from
String oldUsername = mailSender.username
String oldPassword = mailSender.password

// Change the properties here; send the email
try {
CH.config.grails.mail.default.from = "username@domain.com"
mailSender.username = "username@domain.com"
mailSender.password = "sample123!"
mailService.sendMail {
to(['exampple1@domain1.com', 'example2@domain2.com'].toArray())
subject("Example Subject")
body("Sample body")
}
}
catch (Exception e) {
// catch block code
}
// Set the original settings back
finally {
CH.config.grails.mail.default.from = defaultFrom
mailSender.username = oldUsername
mailSender.password = oldPassword
}</pre>
<p>I guess this scenario can be quite prevalent in many projects. Hope you find the blog useful.</p>
<p>- Abhishek Tejpaul</p>
<p>Intelligrape Software Pvt. Ltd.</p>
<p>[<a href="http://www.intelligrape.com" target="_blank">www.intelligrape.com</a>]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.intelligrape.com/blog/2010/06/14/configuring-multiple-senders-in-grails-mail-plugin/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

