lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From DMGoodst...@lbl.gov
Subject Re: QueryParser and escaped characters
Date Tue, 27 Jan 2004 22:38:00 GMT
the analyzer behavior seems to be even more interesting:

import org.apache.lucene.index.*;
import org.apache.lucene.store.*;
import org.apache.lucene.document.*;
import org.apache.lucene.analysis.*;
import org.apache.lucene.analysis.standard.*;
import java.io.*;

public class luceneTest{
  public static void main(String [] args){
    Analyzer myAnalyzer = new StandardAnalyzer();
    final java.io.Reader reader = new
StringReader("ariane-1 ariane\\-1");
    System.out.println("ariane-1 ariane\\-1");
    final TokenStream in =
myAnalyzer.tokenStream(reader);
    try{
    for(;;)
      {
        final org.apache.lucene.analysis.Token token
= in.next();
        
        if (token == null)
          {
            break;
          }
        
        System.out.println("[" + token.termText() +
"]");
      }
    }catch(IOException e){}
  }
} 

$ java luceneTest
ariane-1 ariane\-1
[ariane-1]
[ariane]
[1]



so if i *don't* escape the "-", the standard
analyzer *doesn't* split at the dash..isn't that
opposite the expected behavior?

--David

----- Original Message -----
From: Erik Hatcher <erik@ehatchersolutions.com>
Date: Tuesday, January 27, 2004 1:23 pm
Subject: Re: QueryParser and escaped characters

> Your escape character *is* working to pass it
through the parser 
> into 
> the analyzer.
> 
> It is the analyzer that is splitting at the dash.
 Phrases get 
> analyzed 
> too.
> 
> 	Erik
> 
> p.s. I wish I had a nickel for every Lucene issue
that boils down 
> to 
> QueryParser or Analyzer misunderstanding.  :)  The
two together 
> make 
> for some head-scratching fun, that is for sure.
> 
> On Jan 27, 2004, at 4:00 PM, DMGoodstein@lbl.gov
wrote:
> 
> > I'm constructing a query using queryparser as
follows:
> >
> > Query query = QueryParser.parse("ariadne\-1",
> >                           "default", new
> > StandardAnalyzer());
> >
> >
> > when I print out query.toString(), i get:
> >
> > default:"ariadne 1"
> >
> > I'm not sure why my escape of "-" is not working?
> >
> > --David Goodstein
> >
> >
> >
> >
> >
------------------------------------------------------------------
> ---
> > To unsubscribe, e-mail:
lucene-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
lucene-user-help@jakarta.apache.org
> 
> 
>
--------------------------------------------------------------------
> -
> To unsubscribe, e-mail:
lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
lucene-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Mime
View raw message