• Post Reply Bookmark Topic Watch Topic
  • New Topic

Lucene shortcut syntax  RSS feed

 
Haakon Lind
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I have problem with parsing a text query like this "state-of-the-art -exspensive" where all of the hyphens are handled as NOT short cuts. So I get text:state -text:art -text:exspensive where I ideally would get text:state-of-the-art -text:exspensive, but turning off shortcut syntaxing all together could possibly be acceptable.

Please help me out here, just some hints to where the answer is will also be appreciated.

Thanks!
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am guessing that you are using a QueryParser which does this kind of substitution. Can you construct the queries directly, by using a BooleanQuery of two Terms which are joined by "AND NOT"? Or do you need it to be more general than that?
 
Haakon Lind
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It`s a search string, so I think I need to parse it first....? I`ve also tried to use the WhitespaceAnalyzer with the QueryParser, but it doesn`t seem to preserve the hyphon as it says in the docs.

Thanks
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try escaping all Lucene special characters (like +, -, (, ), [, ], ...) with a backslash. Depending on how you do this it may need to be a double backslash in order to work with Javas escaping rules.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!