--- a/searchengine/cpix/cpix/src/qrytypes/prefixqrytype.cpp Fri May 14 16:57:37 2010 +0300
+++ b/searchengine/cpix/cpix/src/qrytypes/prefixqrytype.cpp Thu May 27 13:59:44 2010 +0300
@@ -31,6 +31,7 @@
#include "initparams.h"
#include "cpixutil.h"
#include "iqrytype.h"
+#include "analyzer.h"
#include "cpixmaindefs.h"
@@ -63,20 +64,28 @@
const std::list<std::wstring> & args,
const wchar_t * qryStr)
{
- wchar_t mQryStr[250];
-
- wmemset(mQryStr,0,250);
- getAnalyzedString(qryStr, mQryStr );
-
- clQueryParser_ = Cast2Native<cpix_QueryParser>(queryParser);
+ wchar_t *mQryStr = NULL;
if (args.size() > 0)
{
THROW_CPIXEXC(PL_ERROR "No arguments needed here");
}
+
+ mQryStr = (wchar_t*) malloc(sizeof(wchar_t)* (2 * wcslen(qryStr)));
+ if(mQryStr == NULL)
+ {
+ THROW_CPIXEXC("Memory allocation failed. Query parsing failed.");
+ }
+
+ wmemset(mQryStr,0,(2 * wcslen(qryStr)));
+ getAnalyzedString(qryStr, mQryStr );
+
+ clQueryParser_ = Cast2Native<cpix_QueryParser>(queryParser);
clQuery_ = clQueryParser_->parse((const wchar_t *)mQryStr);
+ free(mQryStr);
+
if (clQuery_ == NULL)
{
THROW_CPIXEXC("Query reduced to empty query.");
@@ -99,42 +108,43 @@
void getAnalyzedString(const wchar_t* input, wchar_t* output)
{
-
- CL_NS_USE(index)
- CL_NS_USE(util)
- CL_NS_USE(store)
- CL_NS_USE(search)
- CL_NS_USE(document)
- CL_NS_USE(queryParser)
- CL_NS_USE(analysis)
- CL_NS_USE2(analysis,standard)
-
- StandardAnalyzer sAnalyser;
-
- Reader* reader = _CLNEW StringReader(input);
- TokenStream* ts = sAnalyser.tokenStream(_T("dummy"), reader );
- Token t;
-
- while(ts->next(&t))
- {
- wcscat(output,t.termText());
- wcscat(output,L"* ");
- }
- size_t len = wcslen(output);
-
- if(len == 0)
+ CL_NS_USE(index)
+ CL_NS_USE(util)
+ CL_NS_USE(store)
+ CL_NS_USE(search)
+ CL_NS_USE(document)
+ CL_NS_USE(queryParser)
+ CL_NS_USE(analysis)
+ CL_NS_USE2(analysis,standard)
+
+ /*
+ * StandardAnalyzer sAnalyser;
+ * Used before but this but this includes stopwords filters
+ */
+ CustomAnalyzer sAnalyser((const wchar_t*)L"stdtokens>stdfilter>lowercase");
+
+ Reader* reader = _CLNEW StringReader(input);
+ TokenStream* ts = sAnalyser.tokenStream(_T("dummy"), reader );
+ Token t;
+
+ while(ts->next(&t))
+ {
+ wcscat(output,t.termText());
+ wcscat(output,L"* ");
+ }
+ size_t len = wcslen(output);
+
+ if(len == 0)
wcscpy(output,L"*");
- else
- {
- if(output[len-1] == L' ')
+ else
+ {
+ if(output[len-1] == L' ')
output[len-1] = L'\0';
- }
-
- ts->close();
- _CLDELETE(ts);
- _CLDELETE(reader);
-
-
+ }
+
+ ts->close();
+ _CLDELETE(ts);
+ _CLDELETE(reader);
}