Did You Mean: Compass?

2008 February 27
tags:
by Shay Banon

Just finished adding support for spell checking in Compass (available in the nightly builds) which turned out a really cool and easy to use feature. In order to enable spell check in Compass, all that needs to be done is set the following property:

1
compass.engine.spellcheck.enable=true

Next, in the code that performs the search, the following can be done:

1
2
3
4
5
6
CompassQuery query = session.queryBuilder().queryString("fiv").toQuery();
CompassHits hits = query.hits();
System.out.println("Original Query: " + hits.getQuery());
if (hits.getSuggestedQuery().isSuggested()) {
    System.out.println("Did You Mean: " + hits.getSuggestedQuery());
}

Naturally, there are many ways to configure and control this feature, which are all explained in the reference docs, but this is the gist of it.

5 Responses leave one →
  1. 2008 February 28
    vam permalink

    Really cool. I was waiting for this little beauty’s availability

  2. 2008 October 3
    Andrew permalink

    Kimchy, it works well with english words but fails with russian. Could you give some explanations or suggestions to use it with languages other than english?

  3. 2009 May 16

    Hi Shay ,
    Thanks for posting and creating such a nice api… I am using compass in Google app engine, and followed your other blog, and you know it worked perfectly… Thanks a lot… I tested application in production (http://go.simplyshareit.com/index.jsf ) and it is working perfectly…

    I wanted to add this spelling feature also, but don’t know how to set this property in PMF file you wrote…

    Can you help me on this.. Thanks a lot…

    Amit

  4. 2009 May 18

    Hi,
    I found the solution using and it is working
    .setSetting(”compass.engine.spellcheck.enable”,”true”)

    Thanks

Leave a Reply

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS