diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2013-02-13 14:01:53 -0600 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2013-02-27 18:23:14 +0100 |
commit | cb287756a5bafc9882d3ad6bda97049b544ebc7c (patch) | |
tree | 8df4afb6498cef0693dc7fe1800437e501b9141c /bibletime | |
parent | d994385a4f014ec1797500c320f93212749f432e (diff) | |
download | bibletime-cb287756a5bafc9882d3ad6bda97049b544ebc7c.tar.gz bibletime-cb287756a5bafc9882d3ad6bda97049b544ebc7c.zip |
Fix FTBFS with CLucene v2
(cherry picked from commit 9e9e51c2eb3b7bb64e1d68be0d42bae3a4f24f79)
Diffstat (limited to 'bibletime')
-rw-r--r-- | bibletime/backend/cswordmoduleinfo.cpp | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/bibletime/backend/cswordmoduleinfo.cpp b/bibletime/backend/cswordmoduleinfo.cpp index ecb03d0..e03d519 100644 --- a/bibletime/backend/cswordmoduleinfo.cpp +++ b/bibletime/backend/cswordmoduleinfo.cpp @@ -48,9 +48,11 @@ //Lucence includes #include <CLucene.h> +#ifndef CLUCENE_V2 #include <CLucene/util/Reader.h> #include <CLucene/util/Misc.h> #include <CLucene/util/dirent.h> +#endif // CLUCENE_V2 //Increment this, if the index format changes //Then indices on the user's systems will be rebuilt @@ -256,7 +258,9 @@ void CSwordModuleInfo::buildIndex() { util::scoped_ptr<lucene::index::IndexWriter> writer( new lucene::index::IndexWriter(index.ascii(), &an, true) ); //always create a new index writer->setMaxFieldLength(BT_MAX_LUCENE_FIELD_LENGTH); writer->setUseCompoundFile(true); //merge segments into a single file +#ifndef CLUCENE_V2 writer->setMinMergeDocs(1000); +#endif // CLUCENE_V2 *m_module = sword::TOP; unsigned long verseLowIndex = m_module->Index(); @@ -304,13 +308,23 @@ void CSwordModuleInfo::buildIndex() { //index the key lucene_utf8towcs(wcharBuffer, key->getText(), BT_MAX_LUCENE_FIELD_LENGTH); +#ifdef CLUCENE_V2 + lucene::document::Field field1(_T("key"), wcharBuffer, lucene::document::Field::STORE_YES | lucene::document::Field::INDEX_NO); + doc->add(field1); +#else // CLUCENE_V2 doc->add(*lucene::document::Field::UnIndexed(_T("key"), wcharBuffer)); +#endif // CLUCENE_V2 // index the main text //at this point we have to make sure we disabled the strongs and the other options //so the plain filters won't include the numbers somehow. lucene_utf8towcs(wcharBuffer, (const char*) textBuffer.append(m_module->StripText()), BT_MAX_LUCENE_FIELD_LENGTH); +#ifdef CLUCENE_V2 + lucene::document::Field field2(_T("key"), wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED); + doc->add(field2); +#else // CLUCENE_V2 doc->add(*lucene::document::Field::UnStored(_T("content"), wcharBuffer)); +#endif // CLUCENE_V2 textBuffer.resize(0); //clean up // index attributes @@ -321,7 +335,12 @@ void CSwordModuleInfo::buildIndex() { attListI != m_module->getEntryAttributes()["Footnote"].end(); attListI++) { lucene_utf8towcs(wcharBuffer, attListI->second["body"], BT_MAX_LUCENE_FIELD_LENGTH); +#ifdef CLUCENE_V2 + lucene::document::Field field3(_T("footnote"), wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED); + doc->add(field3); +#else // CLUCENE_V2 doc->add(*lucene::document::Field::UnStored(_T("footnote"), wcharBuffer)); +#endif // CLUCENE_V2 } // for attListI // Headings @@ -329,7 +348,12 @@ void CSwordModuleInfo::buildIndex() { attValueI != m_module->getEntryAttributes()["Heading"]["Preverse"].end(); attValueI++) { lucene_utf8towcs(wcharBuffer, attValueI->second, BT_MAX_LUCENE_FIELD_LENGTH); +#ifdef CLUCENE_V2 + lucene::document::Field field4(_T("heading"), wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED); + doc->add(field4); +#else // CLUCENE_V2 doc->add(*lucene::document::Field::UnStored(_T("heading"), wcharBuffer)); +#endif // CLUCENE_V2 } // for attValueI // Strongs/Morphs @@ -339,12 +363,22 @@ void CSwordModuleInfo::buildIndex() { // for each attribute if (attListI->second["LemmaClass"] == "strong") { lucene_utf8towcs(wcharBuffer, attListI->second["Lemma"], BT_MAX_LUCENE_FIELD_LENGTH); +#ifdef CLUCENE_V2 + lucene::document::Field field5(_T("strong"), wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED); + doc->add(field5); +#else // CLUCENE_V2 doc->add(*lucene::document::Field::UnStored(_T("strong"), wcharBuffer)); +#endif // CLUCENE_V2 //qWarning("Adding strong %s", attListI->second["Lemma"].c_str()); } if (attListI->second.find("Morph") != attListI->second.end()) { lucene_utf8towcs(wcharBuffer, attListI->second["Morph"], BT_MAX_LUCENE_FIELD_LENGTH); +#ifdef CLUCENE_V2 + lucene::document::Field field6(_T("morph"), wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED); + doc->add(field6); +#else // CLUCENE_V2 doc->add(*lucene::document::Field::UnStored(_T("morph"), wcharBuffer)); +#endif // CLUCENE_V2 } } // for attListI @@ -409,7 +443,11 @@ const bool CSwordModuleInfo::searchIndexed(const TQString& searchedText, sword:: lucene_utf8towcs(wcharBuffer, searchedText.utf8(), BT_MAX_LUCENE_FIELD_LENGTH); util::scoped_ptr<lucene::search::Query> q( lucene::queryParser::QueryParser::parse(wcharBuffer, _T("content"), &analyzer) ); - util::scoped_ptr<lucene::search::Hits> h( searcher.search(q, lucene::search::Sort::INDEXORDER) ); +#ifdef CLUCENE_V2 + util::scoped_ptr<lucene::search::Hits> h( searcher.search(q, lucene::search::Sort::INDEXORDER()) ); +#else // CLUCENE_V2 + util::scoped_ptr<lucene::search::Hits> h( searcher.search(q, lucene::search::Sort::INDEXORDER) ); +#endif // CLUCENE_V2 const bool useScope = (scope.Count() > 0); // const bool isVerseModule = (type() == CSwordModuleInfo::Bible) || (type() == CSwordModuleInfo::Commentary); @@ -418,7 +456,11 @@ const bool CSwordModuleInfo::searchIndexed(const TQString& searchedText, sword:: util::scoped_ptr<SWKey> swKey( module()->CreateKey() ); +#ifdef CLUCENE_V2 + for (unsigned int i = 0; i < h->length(); ++i) { +#else // CLUCENE_V2 for (int i = 0; i < h->length(); ++i) { +#endif // CLUCENE_V2 doc = &h->doc(i); lucene_wcstoutf8(utfBuffer, doc->get(_T("key")), BT_MAX_LUCENE_FIELD_LENGTH); |