searchengine/cpix/cpix/src/qrytypes/cluceneqrytype.cpp
changeset 1 6f2c1c46032b
parent 0 671dee74050a
child 8 6547bf8ca13a
--- a/searchengine/cpix/cpix/src/qrytypes/cluceneqrytype.cpp	Mon Apr 19 14:40:16 2010 +0300
+++ b/searchengine/cpix/cpix/src/qrytypes/cluceneqrytype.cpp	Mon May 03 13:33:22 2010 +0300
@@ -31,7 +31,10 @@
 #include "cpixutil.h"
 #include "iqrytype.h"
 
-
+//Introduced for prefix optimization.
+#include "prefixopt.h"
+#include "cpixmaindefs.h"
+#include "iqrytype.h"
 
 namespace Cpix
 {
@@ -84,9 +87,16 @@
                 {
                     THROW_CPIXEXC(PL_ERROR "No arguments needed here");
                 }
-            
+
+            //Can we do get rid of this parse here?
             clQuery_ = clQueryParser_->parse(qryStr);
-
+            PrefixOptQueryRewriter prefixOpt_(OPTIMIZED_PREFIX_MAX_LENGTH, 
+                                                    LCPIX_DEFAULT_FIELD, 
+                                                    LCPIX_DEFAULT_PREFIX_FIELD );
+            //Switch query ownership to stack and back
+            std::auto_ptr<lucene::search::Query> q( clQuery_ ); clQuery_ = NULL; 
+            clQuery_ = prefixOpt_.rewrite( q ).release();
+            
             if (clQuery_ == NULL)
                 {
                     THROW_CPIXEXC("Query reduced to empty query.");