2. Search your new index using a prefix query and everything will work as
you expected.
IndexSearcher searcher = new IndexSearcher(reader);
Term term = new Term("title", prefix);
PrefixQuery query = new PrefixQuery(term);
Hits hits = searcher.Search(query);
This PrefixQuery returns "my dog" when the prefix is "dog". How do I avoid
that?
On Wed, Jul 29, 2009 at 2:59 PM, Andrew C. Smith <[email protected]>wrote:
> I would suggest two things to do in order to make this work like you are
> wanting to do.
>
> 1. Use the keyword analyzer to analyze the url field. It may make sense to
> look into using the PerFieldAnalyzerWrapper if you want to index your other
> fields differently. Or you can consider building a separate index for this,
> it's up to you. But the goal here is to use the KeywordAnalyzer.
>
> 2. Search your new index using a prefix query and everything will work as
> you expected.
>
> Hope this helps!
> ~Andrew
>
>
>
> On Wed, Jul 29, 2009 at 8:15 AM, Eric Svensson <[email protected]> wrote:
>
> > I would like to implement automatic phrase suggestion as one type in the
> > searchfield. I have tried different Lucene.net quries without any luck.
> > The functionality I would like is simialr to the SQL Like % method.
> >
> > For instance, if one types "g", "go", "goo", "goog"... I would like "
> > google.com" in the search result, but I don't want "docs.google.com".
> > My main problem is that Lucene.net is searching by terms and I can't
> figure
> > out how to force it to exclude "docs.google.com" from the results.
> >
>