You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lucenenet.apache.org by "Liver-Pitchikan, Kosigin" <kl...@essex.ac.uk> on 2007/07/16 01:35:20 UTC

Wildcard query help (Lucene.net)

Dear all,
 
I'm new to Lucene.net.  I have the indexing and Searching working for
free text.
But when i try the search with Wildcards characters( * and ?). My index
is always coming up with '0' hits.
I have tried below 4 options. All failed. I know i'm doing something
wrong in my side.
Could anyone please let me know the right way to solve my the wildcard
problem. 
 
Option:1
--------
Query searchingxml = new WildcardQuery(new Term("text", "dat*"));
 
Option:2
--------
    BooleanQuery searchingxml  = new BooleanQuery();
    Query query = new WildcardQuery(new Term("text", "wor*"));
    searchingxml .Add(query, true, false);
    
Option 3:
----------
Query searchingxml = new TermQuery(new Term("text", "eng*"))
 
Option 4:
-------------
Query searchingxml = QueryParser.Parse("eng*", "text", new
StandardAnalyzer())
 
----------------
Lucene.Net.Store.RAMDirectory directory = new
Lucene.Net.Store.RAMDirectory("C:\\index");
IndexSearcher searcher = new IndexSearcher(directory);
Hits hits = searcher.Search(searchingxml );
 
 
Any help great fully received. 
 
Many thanks for your time.
 
Regards 
Kosigin

Re: Wildcard query help (Lucene.net)

Posted by Laxmilal Menaria <lm...@chambal.com>.
Hi,

which version of lucene.net are you using ?

I have tested with lucene.net 2.0 its works (option 1,2 and 4 are working)

or you can check the field name case "text", it  is case sensitive..

Thanks
-LM

On 7/16/07, Liver-Pitchikan, Kosigin <kl...@essex.ac.uk> wrote:
>
> Dear all,
>
> I'm new to Lucene.net.  I have the indexing and Searching working for
> free text.
> But when i try the search with Wildcards characters( * and ?). My index
> is always coming up with '0' hits.
> I have tried below 4 options. All failed. I know i'm doing something
> wrong in my side.
> Could anyone please let me know the right way to solve my the wildcard
> problem.
>
> Option:1
> --------
> Query searchingxml = new WildcardQuery(new Term("text", "dat*"));
>
> Option:2
> --------
>     BooleanQuery searchingxml  = new BooleanQuery();
>     Query query = new WildcardQuery(new Term("text", "wor*"));
>     searchingxml .Add(query, true, false);
>
> Option 3:
> ----------
> Query searchingxml = new TermQuery(new Term("text", "eng*"))
>
> Option 4:
> -------------
> Query searchingxml = QueryParser.Parse("eng*", "text", new
> StandardAnalyzer())
>
> ----------------
> Lucene.Net.Store.RAMDirectory directory = new
> Lucene.Net.Store.RAMDirectory("C:\\index");
> IndexSearcher searcher = new IndexSearcher(directory);
> Hits hits = searcher.Search(searchingxml );
>
>
> Any help great fully received.
>
> Many thanks for your time.
>
> Regards
> Kosigin
>



-- 
Thanks,
Laxmilal menaria

http://www.minalyzer.com/
http://www.chambal.com/