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
KeywordAnalyzer());

           Query q = qp.parse("Does this tokenize*");
           System.out.println(q.toString());


Produces
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....

Erick


On 5/12/07, Paul Taylor <[EMAIL PROTECTED]> 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 = is.search(query);
            Iterator i = hits.iterator();
            while(i.hasNext())
            {
                Document doc = ((Hit)i.next()).getDocument();
                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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Reply via email to