lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Currens <currens.ch...@gmail.com>
Subject Re: [Lucene.Net] Phrase search with Wildcard query
Date Wed, 23 Feb 2011 18:50:40 GMT
Check that you're using the same analyzer that you indexed with to search
against that particular field. Also, wildcard queries don't really handle
spaces.  I suggest using the query parser if you want to have multiple terms
to search the same field by.  Considering your previous query, you'll need
to SetAllowLeadingWildcard(true) on the queryparser and remember that the
default operator on the queryparser is OR.  You may want to change that to
AND considering your example.  It's also not a good idea to start your
wildcard query with a wildcard, as it can make searches extremely slow.

You can use Luke (http://code.google.com/p/luke/) to write queries against
your index, if you wanted to test your queries that way.  It also uses the
queryparser to parse it and gives you a human readable parsing of your
query, you can see exactly how lucene interprets it.


Christopher

On Wed, Feb 23, 2011 at 7:51 AM, Wen Gao <samuel.gaowen@gmail.com> wrote:

> Hi,
> I'm using Wildcard query to search phrases, but failed to get results. E.g.
> I search for "*data man*",however, no result returned although there is a
> record of "*data manage*" in my index. I change the "data man" as
> "*data*man*" using following code:
>
> "
> String s = "*" + s.Replace(" ", "*") + "*";
>  WildcardQuery wildquery = new Lucene.Net.Search.WildcardQuery(new
> Lucene.Net.Index.Term("name", keyword));
> .......
> searcher.Search(wildquery);
> "
>
> It works if I only search part of phrase without 'space', e.g.  the record
> returns when i type "*data*".
>
> Any ideas?
>
>
>
> Thanks,
>
> Wen Gao
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message