Re: Searching for a phrase that contains quote character
Daniel Naber writes: On Thursday 28 October 2004 19:03, Justin Swanhart wrote: Have you tried making a term query by hand and testing to see if it works? Term t = new Term(field, this is a \test\); PhraseQuery pq = new PhraseQuery(t); That's not a proper PharseQuery, it searches for *one* term this is a test which is probably not what one wants. You have to add the terms one by one to a PhraseQuery. Will spoke of a keyword field, in which case he would want to search for one term. Using a TermQuery make more sense, though. Morus - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Searching for a phrase that contains quote character
Have you tried making a term query by hand and testing to see if it works? Term t = new Term(field, this is a \test\); PhraseQuery pq = new PhraseQuery(t); ... On Thu, 28 Oct 2004 12:02:48 -0400, Will Allen [EMAIL PROTECTED] wrote: I am having this same problem, but cannot find any help! I have a keyword field that sometimes includes double quotes, but I am unable to search for that field because the escape for a quote doesnt work! I have tried a number of things: myfield:lucene is \cool\ AND myfield:lucene is \\cool\\ http://issues.apache.org/eyebrowse/[EMAIL PROTECTED]msgNo=7351 From: [EMAIL PROTECTED] [EMAIL PROTECTED] Subject: Searching for a phrase that contains quote character Date: Wed, 24 Mar 2004 21:25:16 + I'd like to search for a phrase that contains the quote character. I've tried escaping the quote character, but am receiving a ParseException from the QueryParser: For example to search for the phrase: this is a test I'm trying the following QueryParser.parse(field:\This is a \\\test, field, new StandardAnalyzer()); This results in: org.apache.lucene.queryParser.ParseException: Lexical error at line 1, column 31. Encountered: EOF after : at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:111) at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:87) ... What is the proper way to accomplish this? --Dan - 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]
Re: Searching for a phrase that contains quote character
On Oct 28, 2004, at 1:03 PM, Justin Swanhart wrote: Have you tried making a term query by hand and testing to see if it works? Term t = new Term(field, this is a \test\); PhraseQuery pq = new PhraseQuery(t); That's not accurate API, but add you used pq.add(t), it still would presume that text is all a single term. Chances are, though, that even getting the query to have the quotes is not going to work as you've probably lost the quotes during indexing. Check out the AnalysisParalysis page on the wiki and analyze your Analyzer and make sure you are indexing the text with the quotes (no built-in analyzer besides WhitespaceAnalyzer would do that for you). Erik ... On Thu, 28 Oct 2004 12:02:48 -0400, Will Allen [EMAIL PROTECTED] wrote: I am having this same problem, but cannot find any help! I have a keyword field that sometimes includes double quotes, but I am unable to search for that field because the escape for a quote doesnt work! I have tried a number of things: myfield:lucene is \cool\ AND myfield:lucene is \\cool\\ http://issues.apache.org/eyebrowse/ReadMsg?listName=lucene- [EMAIL PROTECTED]msgNo=7351 From: [EMAIL PROTECTED] [EMAIL PROTECTED] Subject: Searching for a phrase that contains quote character Date: Wed, 24 Mar 2004 21:25:16 + I'd like to search for a phrase that contains the quote character. I've tried escaping the quote character, but am receiving a ParseException from the QueryParser: For example to search for the phrase: this is a test I'm trying the following QueryParser.parse(field:\This is a \\\test, field, new StandardAnalyzer()); This results in: org.apache.lucene.queryParser.ParseException: Lexical error at line 1, column 31. Encountered: EOF after : at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:111) at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:87) ... What is the proper way to accomplish this? --Dan - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Searching for a phrase that contains quote character
I am using a NullAnalyzer for this field. -Original Message- From: Erik Hatcher [mailto:[EMAIL PROTECTED] Sent: Thursday, October 28, 2004 2:00 PM To: Lucene Users List Subject: Re: Searching for a phrase that contains quote character On Oct 28, 2004, at 1:03 PM, Justin Swanhart wrote: Have you tried making a term query by hand and testing to see if it works? Term t = new Term(field, this is a \test\); PhraseQuery pq = new PhraseQuery(t); That's not accurate API, but add you used pq.add(t), it still would presume that text is all a single term. Chances are, though, that even getting the query to have the quotes is not going to work as you've probably lost the quotes during indexing. Check out the AnalysisParalysis page on the wiki and analyze your Analyzer and make sure you are indexing the text with the quotes (no built-in analyzer besides WhitespaceAnalyzer would do that for you). Erik ... On Thu, 28 Oct 2004 12:02:48 -0400, Will Allen [EMAIL PROTECTED] wrote: I am having this same problem, but cannot find any help! I have a keyword field that sometimes includes double quotes, but I am unable to search for that field because the escape for a quote doesnt work! I have tried a number of things: myfield:lucene is \cool\ AND myfield:lucene is \\cool\\ http://issues.apache.org/eyebrowse/ReadMsg?listName=lucene- [EMAIL PROTECTED]msgNo=7351 From: [EMAIL PROTECTED] [EMAIL PROTECTED] Subject: Searching for a phrase that contains quote character Date: Wed, 24 Mar 2004 21:25:16 + I'd like to search for a phrase that contains the quote character. I've tried escaping the quote character, but am receiving a ParseException from the QueryParser: For example to search for the phrase: this is a test I'm trying the following QueryParser.parse(field:\This is a \\\test, field, new StandardAnalyzer()); This results in: org.apache.lucene.queryParser.ParseException: Lexical error at line 1, column 31. Encountered: EOF after : at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:111) at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:87) ... What is the proper way to accomplish this? --Dan - 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] - 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]
Re: Searching for a phrase that contains quote character
On Thursday 28 October 2004 19:03, Justin Swanhart wrote: Have you tried making a term query by hand and testing to see if it works? Term t = new Term(field, this is a \test\); PhraseQuery pq = new PhraseQuery(t); That's not a proper PharseQuery, it searches for *one* term this is a test which is probably not what one wants. You have to add the terms one by one to a PhraseQuery. Regards Daniel -- http://www.danielnaber.de - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Searching for a phrase that contains quote character
absolutely correct. sorry about that. shouldn't code before coffee :) On Thu, 28 Oct 2004 20:16:16 +0200, Daniel Naber [EMAIL PROTECTED] wrote: On Thursday 28 October 2004 19:03, Justin Swanhart wrote: Have you tried making a term query by hand and testing to see if it works? Term t = new Term(field, this is a \test\); PhraseQuery pq = new PhraseQuery(t); That's not a proper PharseQuery, it searches for *one* term this is a test which is probably not what one wants. You have to add the terms one by one to a PhraseQuery. Regards Daniel -- http://www.danielnaber.de - 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]
Re: Searching for a phrase that contains quote character
On Oct 28, 2004, at 2:02 PM, Will Allen wrote: I am using a NullAnalyzer for this field. Which means that each field is added exactly as-is as a single term? Then trying the PhraseQuery directly is a good first step - if you can get that to work then you can move on to making QueryParser work with escaping. But don't complicate things with QueryParser at first. Start with the queries constructed directly first. Erik -Original Message- From: Erik Hatcher [mailto:[EMAIL PROTECTED] Sent: Thursday, October 28, 2004 2:00 PM To: Lucene Users List Subject: Re: Searching for a phrase that contains quote character On Oct 28, 2004, at 1:03 PM, Justin Swanhart wrote: Have you tried making a term query by hand and testing to see if it works? Term t = new Term(field, this is a \test\); PhraseQuery pq = new PhraseQuery(t); That's not accurate API, but add you used pq.add(t), it still would presume that text is all a single term. Chances are, though, that even getting the query to have the quotes is not going to work as you've probably lost the quotes during indexing. Check out the AnalysisParalysis page on the wiki and analyze your Analyzer and make sure you are indexing the text with the quotes (no built-in analyzer besides WhitespaceAnalyzer would do that for you). Erik ... On Thu, 28 Oct 2004 12:02:48 -0400, Will Allen [EMAIL PROTECTED] wrote: I am having this same problem, but cannot find any help! I have a keyword field that sometimes includes double quotes, but I am unable to search for that field because the escape for a quote doesnt work! I have tried a number of things: myfield:lucene is \cool\ AND myfield:lucene is \\cool\\ http://issues.apache.org/eyebrowse/ReadMsg?listName=lucene- [EMAIL PROTECTED]msgNo=7351 From: [EMAIL PROTECTED] [EMAIL PROTECTED] Subject: Searching for a phrase that contains quote character Date: Wed, 24 Mar 2004 21:25:16 + I'd like to search for a phrase that contains the quote character. I've tried escaping the quote character, but am receiving a ParseException from the QueryParser: For example to search for the phrase: this is a test I'm trying the following QueryParser.parse(field:\This is a \\\test, field, new StandardAnalyzer()); This results in: org.apache.lucene.queryParser.ParseException: Lexical error at line 1, column 31. Encountered: EOF after : at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:111) at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:87) ... What is the proper way to accomplish this? --Dan - 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] - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Searching for a phrase that contains quote character
The nullanalyzer overrides the isTokenChar method to simply return true in the tokenizer class (http://issues.apache.org/eyebrowse/[EMAIL PROTECTED]msgId=1703655). The situation is that it seems lucene does not expect you to escape characters that exist inside of a quoted string. So my search [ authorkeyword:MariaMy* ] works, but [ authorkeyword:MariaMy\* ] does not, even though the * character should be escaped (http://jakarta.apache.org/lucene/docs/queryparsersyntax.html#Terms) So, if this is true, then the rule might be, reserved characters must be escaped EXCEPT when they are within double quotes as a phrase. When double quotes are needed within a phrase, they should be escaped with a .. ? -Original Message- From: Erik Hatcher [mailto:[EMAIL PROTECTED] Sent: Thursday, October 28, 2004 3:05 PM To: Lucene Users List Subject: Re: Searching for a phrase that contains quote character On Oct 28, 2004, at 2:02 PM, Will Allen wrote: I am using a NullAnalyzer for this field. Which means that each field is added exactly as-is as a single term? Then trying the PhraseQuery directly is a good first step - if you can get that to work then you can move on to making QueryParser work with escaping. But don't complicate things with QueryParser at first. Start with the queries constructed directly first. Erik -Original Message- From: Erik Hatcher [mailto:[EMAIL PROTECTED] Sent: Thursday, October 28, 2004 2:00 PM To: Lucene Users List Subject: Re: Searching for a phrase that contains quote character On Oct 28, 2004, at 1:03 PM, Justin Swanhart wrote: Have you tried making a term query by hand and testing to see if it works? Term t = new Term(field, this is a \test\); PhraseQuery pq = new PhraseQuery(t); That's not accurate API, but add you used pq.add(t), it still would presume that text is all a single term. Chances are, though, that even getting the query to have the quotes is not going to work as you've probably lost the quotes during indexing. Check out the AnalysisParalysis page on the wiki and analyze your Analyzer and make sure you are indexing the text with the quotes (no built-in analyzer besides WhitespaceAnalyzer would do that for you). Erik ... On Thu, 28 Oct 2004 12:02:48 -0400, Will Allen [EMAIL PROTECTED] wrote: I am having this same problem, but cannot find any help! I have a keyword field that sometimes includes double quotes, but I am unable to search for that field because the escape for a quote doesnt work! I have tried a number of things: myfield:lucene is \cool\ AND myfield:lucene is \\cool\\ http://issues.apache.org/eyebrowse/ReadMsg?listName=lucene- [EMAIL PROTECTED]msgNo=7351 From: [EMAIL PROTECTED] [EMAIL PROTECTED] Subject: Searching for a phrase that contains quote character Date: Wed, 24 Mar 2004 21:25:16 + I'd like to search for a phrase that contains the quote character. I've tried escaping the quote character, but am receiving a ParseException from the QueryParser: For example to search for the phrase: this is a test I'm trying the following QueryParser.parse(field:\This is a \\\test, field, new StandardAnalyzer()); This results in: org.apache.lucene.queryParser.ParseException: Lexical error at line 1, column 31. Encountered: EOF after : at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:111) at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:87) ... What is the proper way to accomplish this? --Dan - 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] - 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] - 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]