From: norbert b. <nor...@di...> - 2015-02-23 13:55:20
|
Hello, There's something I'm having trouble understanding with the Keyword Analyzer. I'm indexing elements with a field named /type/, in which I put the value /hello world/, using the INDEX_TOKENIZED flag. With a WhitespaceAnalyzer, the field becomes split into 2 terms in the index :/type=hello/ and /type=world/. Fine. With a KeywordAnalyzer, there's only 1 term, /type=hello world/. Perfect. But my problem is when I build my search queries, using the QueryParser : QueryParser lParser( _T( "type" ), lAnalyzer ); Query* lQuery = lParser.parse( _T( "hello world*" ) ); (That * at the end is important for reasons I don't need to explain here) This results in my search query being (type:hello type:world*), no matter which analyzer I use (Whitespace or Keyword). I'm guessing this is normal, because the Lucene Syntax rules take whitespaces as separators between different terms. The analyzer doesn't have any influence on that (correct me if I'm wrong). To prevent that, I should put /hello world/ between " ", so the whitespace isn't taken into account. But if I do that, where can I put my * at the end ? If I give the parser/"hello world*"/, the * isn't processed as a wildcard. If I give the parser /"hello world"*/, the query becomes (type:hello world type:*), which isn't ok. Any help ? I'm probably missing something. As a side question, what's the influence of an Analyzer in the QueryParser ? Thanks ! |