lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Taylor <paul_t...@fastmail.fm>
Subject Problem using wildcardsearch in phrase search
Date Sat, 12 May 2007 17:02:54 GMT
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: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message