How to do spellcheck in Solr?

To do spellCheck in Solr you need to follow below given steps:

1. In your solrconfig.xml make following changes:

Most important add solr.SpellCheckComponent to solrconfig.xml file. As shown below:

<searchComponent name=”spellcheck” class=”solr.SpellCheckComponent”> // class for spellCheck mechanism
<lst name=”spellchecker”>
<str name=”classname”>solr.IndexBasedSpellChecker</str>
<str name=”spellcheckIndexDir”>./spellchecker</str> /*directory name which holds the spellcheck index*/
<str name=”field”>content</str>
<str name=”buildOnCommit”>true</str>

2. Add handler to use above defined components. As shown below:

<requestHandler name=”standard” class=”solr.SearchHandler” default=”true”>
<lst name=”defaults”>
<str name=”echoParams”>explicit</str>
<str name=”spellcheck”>true</str>
<str name=”spellcheck.collate”>true</str>
<arr name=”last-components”>

3. Now , make changes to schema.xml file:

     <field name=”content” type=”text” indexed=”true” stored=”false” multiValued=”true”/>

<fieldType name=”text” positionIncrementGap=”100″>
<tokenizer class=”solr.WhitespaceTokenizerFactory”/>
<filter class=”solr.PatternReplaceFilterFactory” pattern=”‘” replacement=”” replace=”all” />
<filter class=”solr.WordDelimiterFilterFactory”
<filter class=”solr.LowerCaseFilterFactory”/>

Now, your Solr is ready with spell Check Functionality.

ProsperaSoft offers Solr development solutions. You can email at to get in touch with ProsperaSoft Solr experts and consultants.


How to filter data based on type of user?

Solr does not have document-level security, so you would have to retrieve and index access control lists for each document. Then you need to apply a filter query to every search and pass in the user’s security group and/or username.

Let’s say your document is indexed like this, where the values for the multivalued field “access” is determined at index time by the actual permissions on the file:

<field name=”id”>42</field>
<field name=”name”>Products.xlsx</field>
<field name=”title”>Product list</field>
<field name=”content”>…</field>
<field name=”access”>OFFICE\Manager</field>
<field name=”access”>OFFICE\Staff</field>
Then you can decorate the query request handler with a default filter query parameter in solrconfig.xml:

<requestHandler name=”/select” class=”solr.SearchHandler”>
<str name=”fq”>access:”OFFICE\Everyone”</str>
Now searches by default will not return the Products.xlsx document, since the default ‘user’ that is impersonated (namely “OFFICE\Everyone”) does not appear in the “access” field. But as soon as you pass in an actual user’s group to override the default filter query, Solr will return the document:

/solr/collection1/select?q=content:”product x”&fq=access:”OFFICE\Manager”
Of course when the permissions change, the index must be updated as soon as possible to reflect this.

ProsperaSoft offers Solr development solutions. You can email at to get in touch with ProsperaSoft Solr experts and consultants.


How to stop solr using jetty?

To start and stop Solr using jetty we have following commands:

Starting solr with Jetty –

java -DSTOP.PORT=8079 -DSTOP.KEY=mysecret -jar start.jar

Stopping Solr with Jetty –

java -DSTOP.PORT=8079 -DSTOP.KEY=mysecret -jar start.jar –stop

ProsperaSoft offers Solr development solutions. You can email at to get in touch with ProsperaSoft Solr experts and consultants.

How to configure Spring security in Grails

Following are the steps to configure spring security in grails:

1. Create project using  command grails create-app projectName.

2.  Configure Spring security core

First of all, we have to install Spring Security Core plugin into our project. Edit  BuildConfig.groovy and modify the plugins section as below:

plugins {

// plugins for the build system only
build “:tomcat:7.0.42″

// plugins for the compile step
compile “:scaffolding:2.0.0″
compile ‘:cache:1.1.1′

// plugins needed at runtime but not for compilation
runtime “:hibernate:″ // or “:hibernate4:″
runtime “:database-migration:1.3.5″
runtime “:jquery:1.10.2″ // <– If using 1.8.3, update to this version
runtime “:resources:1.2″

compile ‘:spring-security-core:2.0-RC2′ //Added


Then run (optionally grails cleangrails compile while in project’s directory to have the plugin installed.

3. Let Spring Security Core plugin to create required  models and controllers for us. For that we have to run command


This will create 3 domain classes User, Role and UserRole.

And also in controller it will create 2 controllers LoginController and LogoutController which along with views/login/auth.gsp and views/login/denied.gsp.

4. Add the end of Config.groovy file you can see these lines added by spring security plugin

// Added by the Spring Security Core plugin:
grails.plugin.springsecurity.userLookup.userDomainClassName =      ‘’
grails.plugin.springsecurity.userLookup.authorityJoinClassName       = ‘’
grails.plugin.springsecurity.authority.className =     ‘’

5. At this step, Spring Security Core is configured properly.

Edit  BootStrap.groovy to tell Grails about our sample    users/roles.


class BootStrap {

def init = { servletContext ->
def adminRole = new Role(authority: ‘ROLE_ADMIN’).save(flush: true)
def userRole = new Role(authority: ‘ROLE_USER’).save(flush: true)

def testUser = new User(username: ‘admin’, enabled: true, password: ‘admin’) true)

UserRole.create testUser, adminRole, true

assert User.count() == 1
assert Role.count() == 2
assert UserRole.count() == 1

def destroy = {

6. Now you can use @Secured to to secure access to methods of controller based on roles. For example,


def index(){

render ‘Some sensitive data’



ProsperaSoft offers Grails development solutions. You can email at to get in touch with ProsperaSoft Grails experts and consultants.

Solr Schema Design Considerations

Indexed Fields

The number of indexed fields greatly increases the following:

  • Memory usage during indexing
  • Segment merge time
  • Optimization times
  • Index size

These effects can be reduced by the use of omitNorms=”true”


    • This is arguably an advanced option.
    • Set to true to omit the norms associated with this field (this disables length normalization and index-time boosting for the field, and saves some memory). Only full-text fields or fields that need an index-time boost need norms.
  1. Choose between “text” and “string” field property

Stored fields

Retrieving the stored fields of a query result can be a significant expense. This cost is affected largely by the number of bytes stored per document–the higher byte count, the sparser the documents will be distributed on disk and more I/O is necessary to retrieve the fields (usually this is a concern when storing large fields, like the entire contents of a document).

Consider storing large fields outside of Solr. If you feel inclined to do so regardless, consider using compressed fields, which increase the CPU cost of storing and retrieving the fields, but lowers the I/O burden and CPU usage.

If you aren’t always using all the stored fields, then enabling lazy field loading can be a huge boon, especially if compressed fields are used.