lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <e...@ehatchersolutions.com>
Subject Re: Searching for a phrase that contains quote character
Date Thu, 28 Oct 2004 19:05:28 GMT
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:erik@ehatchersolutions.com]
> 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
>> <wallen@cyveillance.com> 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-
>>> user@jakarta.apache.org&msgNo=7351
>>>
>>> From: danrapp@comcast.net <danrapp@comcast.net>
>>> Subject: Searching for a phrase that contains quote character
>>> Date: Wed, 24 Mar 2004 21:25:16 +0000
>>>
>>> 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: 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
>
>
> ---------------------------------------------------------------------
> 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