Hello,
I never used QueryParser::parse static method so I'm not sure, but if you pass
a complex query as first parameter it should return correct Query object
Please note this static method is marked /** For backward compatibility */ in
source code, so better way is to create QueryParser object
and call member parse(const TCHAR* _query) method. This avoid creation of new
parser object for each query you parse so it is a bit more efficient.
Borek
From: norbert barichard [mailto:norbert.barich...@diginext.fr]
Sent: Friday, January 23, 2015 2:31 PM
To: clucene-developers@lists.sourceforge.net
Subject: [CLucene-dev] Parsing queries ?
Hello,
I would like to know if there is a way (in CLucene2.3.3.4) to build a Query*
object from a complete Lucene query string, taking into account all of its
operators (AND, OR, NOT, +, -, :, (), etc.). Until now, I've been able to use
the QueryParser to build fairly simple queries, like this for example :
/*******/
BooleanQuery* lBoolQuery = new BooleanQuery();
Query* lQuery1 = QueryParser::parse( _T( "sampleValue1" ), _T( "sampleField1"
), lAnalyzer );
Query* lQuery2 = QueryParser::parse( _T( "sampleValue2" ), _T( "sampleField2"
), lAnalyzer );
lBoolQuery ->add( lQuery1, true, BooleanClause::MUST );
lBoolQuery->add( lQuery2, true, BooleanClause::MUST );
/*******/
This works ok. But if I've got a complex Lucene string query, like :
"title:(test -stuff) AND text:"hello wor*") OR "something nice"^4 ... How can I
use this to get a Query* object representing this request ? I'm assuming there
is a method to do that, I just can't find it. And I don't want to write a
parser myself !
Thanks in advance,
--
[cid:image001.png@01D03728.79E22E30]
------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
CLucene-developers mailing list
CLucene-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/clucene-developers