Did You Mean: Compass?

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.

2 Responses to “Did You Mean: Compass?”

  1. vam Says:

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

  2. Mathieu Says:

    Have a look at https://issues.apache.org/jira/browse/LUCENE-1190

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>