I return back to Luke toolbox, searching by "R\&D" with
org.apache.lucene.analysis.KeywordAnalyzer on the same index. But I got no
result. 

Perhaps I was wrong built the index? Not sure,;-(


Partout wrote:
> 
> Alexander, 
> 
> My script section is below:
> 
>                 ......
>                 Zend_Search_Lucene_Analysis_Analyzer::setDefault(new
> Zend_Search_Lucene_Analysis_Analyzer_Commo
> n_TextNum_CaseInsensitive());
>                
> Zend_Search_Lucene_Search_QueryParser::setDefaultOperator(Zend_Search_Lucene_Search_QueryParser
> ::B_AND);
>                 $search = "R\&D";   //I have tried "R\\&D",
> '"R\&D"',"R&D",'"R&D"' 
>                 $query =
> Zend_Search_Lucene_Search_QueryParser::parse($search);
>                 echo $query->__toString() . "\n";
>                 $hits = $index->find($query);
>                 ......
> 
> Result output:
> 
>                 "R\&D" --> +(+r +d) 
>                 "R\\&D" --> +(+r +d) 
>                 '"R\&D"' --> +("r d") 
>                 "R&D" --> 
> 'Zend_Search_Lucene_Search_QueryParserException' with message 'Two chars
> lexeme expected. Position is 2.'
>                 '"R&D"' --> +("r d") 
> 
> Besides, I also built the index with
> Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive()
> option.
> 
> Is there still other way to solve my problem? Thank you very much.
> 
> Best regards,
> 
> David
> 
> 
> Alexander Veremyev wrote:
>> 
>> Hi,
>> 
>> Are you sure that escaping "\&" wasn't translated into '&' before 
>> sending it to query parser?
>> 
>> Please try "R\\&D".
>> 
>> 
>> In addition to this you need special analyzer to consider R&D as one 
>> word (default analyzer translates it into phrase "r d").
>> 
>> Take a look on 
>> Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive 
>> class and Zend_Search_Lucene_Analysis_Analyzer::setDefault() method.
>> http://framework.zend.com/manual/en/zend.search.extending.html#zend.search.extending.analysis
>> 
>> 
>> With best regards,
>>     Alexander Veremyev.
>> 
>> 
>> 
>> Partout wrote:
>>> Hi All, I am using Zend_Search, and glad to see many new enhancements 
>>> were added. Many thanks to all of you. But still a question, that is, I 
>>> need to search some words just like "R&D", "J2EE" .... Who can tell me 
>>> how to get it? I have used "R\&D", but it throw exception below: /Fatal 
>>> error: Uncaught exception 
>>> 'Zend_Search_Lucene_Search_QueryParserException' with message 'Two chars 
>>> lexeme expected. Position is 4.' in 
>>> /opt/system/Zend/Search/Lucene/Search/QueryLexer.php:397 Stack trace: #0 
>>> /opt/system/Zend/Search/Lucene/FSMAction.php(62): 
>>> Zend_Search_Lucene_Search_QueryLexer->addQuerySyntaxLexeme() ...../ 
>>> Thanks in advance. David
>>> ------------------------------------------------------------------------
>>> View this message in context: How could Zend_Search be used to search 
>>> word like "R&D"? 
>>> <http://www.nabble.com/How-could-Zend_Search-be-used-to-search-word-like-%22R-D%22--tf3734766s16154.html#a10454147>
>>> Sent from the Zend Framework mailing list archive 
>>> <http://www.nabble.com/Zend-Framework-f15440.html> at Nabble.com.
>> 
>> 
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/How-could-Zend_Search-be-used-to-search-word-like-%22R-D%22--tf3734766s16154.html#a10607861
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to