2

If not how do you make this work with them and which is better?

e.g. when searching for "mi" i would like results with "microsoft" to potentially show up in a result even though there is no "keyword" like "mi" specifically.

algorithmicCoder
  • 6,595
  • 20
  • 68
  • 117
  • Relevant: http://stackoverflow.com/questions/737275/pros-cons-of-full-text-search-engine-lucene-sphinx-postgresql-full-text-searc – Aleksi Yrttiaho Apr 03 '11 at 01:39

1 Answers1

4

Yes and Yes.

Lucene has PrefixQuery:

BooleanQuery query = new BooleanQuery();
for (String token : tokenize(queryString)) {
  query.add(new PrefixQuery(new Term(LABEL_FIELD_NAME, token)), Occur.MUST);
}
return query;

You can also use the Lucene query parser syntax and define the prefix search by using a wildcard exam*. The query parser syntax works if you want to deploy a separate Lucene search server, Solr, that is called using a HTTP API

In Sphinx it seams you have to do the following:

  1. Set minimum prefix length to a value larger than 0
  2. Enable wildcard syntax
  3. Generate a query string with a willdcard exam*
Aleksi Yrttiaho
  • 8,266
  • 29
  • 36
  • I've used the wildcard syntax to provide autocomplete and google live type results with sphinx. You'd start typing "New " and it would offer "New York Times, New York Post" etc. It was fast enough to provide this with ajax. – preinheimer Apr 03 '11 at 01:38