aspose file tools
The moose likes Other JSE/JEE APIs and the fly likes Lucene shortcut syntax Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Reply Bookmark "Lucene shortcut syntax" Watch "Lucene shortcut syntax" New topic
Author

Lucene shortcut syntax

Haakon Lind
Greenhorn

Joined: Sep 18, 2002
Posts: 22
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
Marshal

Joined: Mar 22, 2005
Posts: 35258
    
    7
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?


Android appsImageJ pluginsJava web charts
Haakon Lind
Greenhorn

Joined: Sep 18, 2002
Posts: 22
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
Marshal

Joined: Mar 22, 2005
Posts: 35258
    
    7
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Lucene shortcut syntax
 
Similar Threads
Regarding Objects Generated by Objects
.jar shortcut in windows??? an easy question im sure...
bitwise ^ on Exam?
My pony tripped over the first gopher hole..
a question in stacks