I think the KeywordAnlyser bit is maybe a red herring, the problem seems to be that you cant use * within double quotes, I made some changes to my data and index to remove the space character

If I fed 54:puid* to my code it generates a Prefix Query and works as required
Search Query Is54:puid*
Parsed Search Query Is54:puid*of type:class org.apache.lucene.search.PrefixQuery

but with the quotes (which I would need if my value contained spaces) I only get a Term Query (which doesnt handle wildcards)
Search Query Is54:"puid*"
Parsed Search Query Is54:puid*of type:class org.apache.lucene.search.TermQuery

so why is this ?

thanks Paul

code is:
public List <Integer> generalSearch(String luceneSearch)
   {
       System.out.println("Search Query Is"+luceneSearch);
       List <Integer> matchingRows = new ArrayList<Integer>();
       try
       {
           //make a new index searcher with the inmemory (RAM) index.
           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);
System.out.println("Parsed Search Query Is"+query.toString()+"of type:"+query.getClass());
           //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();
       }
       System.out.println("Search Query Results Set:"+matchingRows.size());
       return matchingRows;
   }


Mark Miller wrote:



Perhaps not like whitespaceanalyzer does in all cases, but this code

           QueryParser qp = new QueryParser("field", new
WhitespaceAnalyzer());

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

produces

field:Does field:this field:tokenize*



while 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*

The only difference is using KeywordAnalyzer rather than WhitespaceAnalyzer.

I sure don't see the difference, and it's puzzled me on and off.

Erick
QueryParser breaks up "Does this tokenize*" before it even gets to the Analyzer...each space separated term is fed to the analyzer one at a time...unless they are surrounded in quotes in which case the whole string in the quotes is fed into the analyzer.

- Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to