lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Erick Erickson" <>
Subject Re: Problem using wildcardsearch in phrase search
Date Sat, 12 May 2007 17:54:45 GMT
Somewhere in the list, I remember one of the guys who know what
they're talking about mentions something about KeywordAnalyzer
being "subject to the meta-semantics of the QueryParser".

So try looking at query.toString() in your example. What I think you'll
find is that KeywordAnalyzer doesn't quite do what you expect at
query time. This code

            QueryParser qp = new QueryParser("field", new

            Query q = qp.parse("Does this tokenize*");

field:Does field:this field:tokenize*

which isn't really what you're looking for, I don't think. In fact, I don't
see any difference between this and WhitespaceAnalyzer. What I
think you want is

Try rewriting the query and dumping the output to see how your
term expands...

If you haven't already, get a copy of Luke (google Lucene Luke). That'll
allow you to examine how different analyzers work at query time and
give you a much better idea of what is going on.....

But it's a beautiful Saturday, and I'm going to go outside and garden so....


On 5/12/07, Paul Taylor <> wrote:
> I seem to be having problems using a * in a phrase term query
> This is my search String, its not finding any matches
> 54:"MusicIP PUID*"
> If I match on a particular record it works ok
> 54:"MusicIP PUIDa39494bf-927e-1638-fb06-782ec55ac22d"
> The problem appears to be the space character, because I have another
> situation where there is no space and it works ok.
> I use a keyword analyser to create the index so the value 'MusicIP
> PUIDa39494bf-927e-1638-fb06-782ec55ac22d' is stored
> as a single value, and then use the same analyser in my search code,
> which is as follows:
> public List <Integer> generalSearch(String luceneSearch)
>     {
>         System.out.println("Search Query Is"+luceneSearch);
>         List <Integer> matchingRows = new ArrayList<Integer>();
>         try
>         {
>             IndexSearcher is = new IndexSearcher(directory);
>             //Build a query based on the searchString and cached analyzer
>             QueryParser parser = new QueryParser(ROW_NUMBER,analyzer);
>             Query query = parser.parse(luceneSearch);
>             //run the search
>             Hits hits =;
>             Iterator i = hits.iterator();
>             while(i.hasNext())
>             {
>                 Document doc = ((Hit);
>                 matchingRows.add(new
> Integer(doc.getField(ROW_NUMBER).stringValue()));
>             }
>         }
>         catch (Exception e)
>         {
>             e.printStackTrace();
>         }
>         return matchingRows;
>     }
> I cant see what the problem is, thanks paul
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

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