summaryrefslogtreecommitdiff
path: root/src/modules/swmodule.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/swmodule.cpp')
-rw-r--r--src/modules/swmodule.cpp77
1 files changed, 52 insertions, 25 deletions
diff --git a/src/modules/swmodule.cpp b/src/modules/swmodule.cpp
index 3eb7ce1..758b8d2 100644
--- a/src/modules/swmodule.cpp
+++ b/src/modules/swmodule.cpp
@@ -432,9 +432,9 @@ ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *sc
#ifdef USELUCENE
SWBuf target = getConfigEntry("AbsoluteDataPath");
- char ch = target.c_str()[strlen(target.c_str())-1];
- if ((ch != '/') && (ch != '\\'))
+ if (!target.endsWith("/") && !target.endsWith("\\")) {
target.append('/');
+ }
target.append("lucene");
#endif
if (justCheckIfSupported) {
@@ -461,6 +461,8 @@ ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *sc
// determine if we might be doing special strip searches. useful for knowing if we can use shortcuts
bool specialStrips = (getConfigEntry("LocalStripFilter")
|| (getConfig().has("GlobalOptionFilter", "UTF8GreekAccents"))
+ || (getConfig().has("GlobalOptionFilter", "UTF8HebrewPoints"))
+ || (getConfig().has("GlobalOptionFilter", "UTF8ArabicPoints"))
|| (strchr(istr, '<')));
processEntryAttributes(searchType == -3);
@@ -509,7 +511,8 @@ ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *sc
is = new IndexSearcher(ir);
(*percent)(10, percentUserData);
- standard::StandardAnalyzer analyzer;
+ const TCHAR *stopWords[] = { 0 };
+ standard::StandardAnalyzer analyzer(stopWords);
lucene_utf8towcs(wcharBuffer, istr, MAX_CONV_SIZE); //TODO Is istr always utf8?
q = QueryParser::parse(wcharBuffer, _T("content"), &analyzer);
(*percent)(20, percentUserData);
@@ -672,7 +675,8 @@ ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *sc
resultKey->clearBound();
listKey << *resultKey;
}
- } break;
+ }
+ break;
// entry attributes
case -3: {
@@ -683,10 +687,15 @@ ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *sc
AttributeValue::iterator i3Start, i3End;
if ((words.size()) && (words[0].length())) {
+// cout << "Word: " << words[0] << endl;
+ for (i1Start = entryAttribs.begin(); i1Start != entryAttribs.end(); ++i1Start) {
+// cout << "stuff: " << i1Start->first.c_str() << endl;
+ }
i1Start = entryAttribs.find(words[0]);
i1End = i1Start;
- if (i1End != entryAttribs.end())
- i1End++;
+ if (i1End != entryAttribs.end()) {
+ i1End++;
+ }
}
else {
i1Start = entryAttribs.begin();
@@ -846,7 +855,13 @@ const char *SWModule::StripText(const char *buf, int len) {
*/
const char *SWModule::RenderText(const char *buf, int len, bool render) {
- entryAttributes.clear();
+ bool savePEA = isProcessEntryAttributes();
+ if (!buf) {
+ entryAttributes.clear();
+ }
+ else {
+ processEntryAttributes(false);
+ }
static SWBuf local;
if (buf)
@@ -874,6 +889,8 @@ const char *SWModule::StripText(const char *buf, int len) {
tmpbuf = null;
}
+ processEntryAttributes(savePEA);
+
return tmpbuf;
}
@@ -962,9 +979,9 @@ bool SWModule::hasSearchFramework() {
void SWModule::deleteSearchFramework() {
#ifdef USELUCENE
SWBuf target = getConfigEntry("AbsoluteDataPath");
- char ch = target.c_str()[strlen(target.c_str())-1];
- if ((ch != '/') && (ch != '\\'))
+ if (!target.endsWith("/") && !target.endsWith("\\")) {
target.append('/');
+ }
target.append("lucene");
FileMgr::removeDir(target.c_str());
@@ -975,12 +992,23 @@ void SWModule::deleteSearchFramework() {
signed char SWModule::createSearchFramework(void (*percent)(char, void *), void *percentUserData) {
+
#ifdef USELUCENE
+ SWBuf target = getConfigEntry("AbsoluteDataPath");
+ if (!target.endsWith("/") && !target.endsWith("\\")) {
+ target.append('/');
+ }
+ target.append("lucene");
+ int status = FileMgr::createParent(target+"/dummy");
+ if (status) return -1;
+
SWKey *saveKey = 0;
SWKey *searchKey = 0;
SWKey textkey;
SWBuf c;
+ const int MAX_CONV_SIZE = 1024 * 1024;
+ wchar_t *wcharBuffer = new wchar_t[MAX_CONV_SIZE + 1];
// turn all filters to default values
StringList filterSettings;
@@ -988,7 +1016,10 @@ signed char SWModule::createSearchFramework(void (*percent)(char, void *), void
filterSettings.push_back((*filter)->getOptionValue());
(*filter)->setOptionValue(*((*filter)->getOptionValues().begin()));
- if (!strcmp("Greek Accents", (*filter)->getOptionName())) {
+ if ( (!strcmp("Greek Accents", (*filter)->getOptionName())) ||
+ (!strcmp("Hebrew Vowel Points", (*filter)->getOptionName())) ||
+ (!strcmp("Arabic Vowel Points", (*filter)->getOptionName()))
+ ) {
(*filter)->setOptionValue("Off");
}
}
@@ -1011,22 +1042,19 @@ signed char SWModule::createSearchFramework(void (*percent)(char, void *), void
setKey(*searchKey);
}
- RAMDirectory *ramDir = NULL;
- IndexWriter *coreWriter = NULL;
- IndexWriter *fsWriter = NULL;
- Directory *d = NULL;
+ RAMDirectory *ramDir = 0;
+ IndexWriter *coreWriter = 0;
+ IndexWriter *fsWriter = 0;
+ Directory *d = 0;
- standard::StandardAnalyzer *an = new standard::StandardAnalyzer();
- SWBuf target = getConfigEntry("AbsoluteDataPath");
+ const TCHAR *stopWords[] = { 0 };
+ standard::StandardAnalyzer *an = new standard::StandardAnalyzer(stopWords);
bool includeKeyInSearch = getConfig().has("SearchOption", "IncludeKeyInSearch");
- char ch = target.c_str()[strlen(target.c_str())-1];
- if ((ch != '/') && (ch != '\\'))
- target.append('/');
- target.append("lucene");
- FileMgr::createParent(target+"/dummy");
ramDir = new RAMDirectory();
coreWriter = new IndexWriter(ramDir, an, true);
+ coreWriter->setMaxFieldLength(MAX_CONV_SIZE);
+
@@ -1056,9 +1084,6 @@ signed char SWModule::createSearchFramework(void (*percent)(char, void *), void
SWBuf proxLem;
SWBuf strong;
- const short int MAX_CONV_SIZE = 2047;
- wchar_t wcharBuffer[MAX_CONV_SIZE + 1];
-
char err = Error();
while (!err) {
long mindex = key->Index();
@@ -1287,7 +1312,7 @@ signed char SWModule::createSearchFramework(void (*percent)(char, void *), void
fsWriter = new IndexWriter( d, an, false);
} else {
d = FSDirectory::getDirectory(target.c_str(), true);
- fsWriter = new IndexWriter( d ,an, true);
+ fsWriter = new IndexWriter(d, an, true);
}
Directory *dirs[] = { ramDir, 0 };
@@ -1318,6 +1343,8 @@ signed char SWModule::createSearchFramework(void (*percent)(char, void *), void
(*filter)->setOptionValue(*origVal++);
}
+ delete [] wcharBuffer;
+
return 0;
#else
return SWSearchable::createSearchFramework(percent, percentUserData);