summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Pearson <[email protected]>2013-02-13 14:01:53 -0600
committerTimothy Pearson <[email protected]>2013-02-13 14:01:53 -0600
commit9e9e51c2eb3b7bb64e1d68be0d42bae3a4f24f79 (patch)
treefec599cdc57bc6d1cd5377ffc39425fb9e3464d1
parent9962399a82af4deb740597a3953b53d1d43197d9 (diff)
downloadbibletime-9e9e51c2eb3b7bb64e1d68be0d42bae3a4f24f79.tar.gz
bibletime-9e9e51c2eb3b7bb64e1d68be0d42bae3a4f24f79.zip
Fix FTBFS with CLucene v2
m---------admin0
-rw-r--r--bibletime/backend/cswordmoduleinfo.cpp44
-rw-r--r--clucene.m418
3 files changed, 58 insertions, 4 deletions
diff --git a/admin b/admin
-Subproject 39466b7b95f25a3e0f6da52b156b194b10cbac9
+Subproject c5cef804fe69e65e2e2f76df31fdbc7d4a4650e
diff --git a/bibletime/backend/cswordmoduleinfo.cpp b/bibletime/backend/cswordmoduleinfo.cpp
index f799fb4..f39ecd7 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
//tqWarning("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);
diff --git a/clucene.m4 b/clucene.m4
index 09817d8..e643e75 100644
--- a/clucene.m4
+++ b/clucene.m4
@@ -28,7 +28,8 @@ AC_ARG_ENABLE(static-clucene,
dnl try to find CLucene library files
AC_MSG_CHECKING([for CLucene library files])
-ac_clucene_library_dirs="$ac_clucene_dir/lib $exec_prefix/lib $prefix/lib /usr/lib /usr/lib64 /usr/local/lib"
+clucene_multiarch_libs="/usr/lib/`uname -m`-linux-gnu"
+ac_clucene_library_dirs="$ac_clucene_dir/lib $exec_prefix/lib $prefix/lib /usr/lib /usr/lib64 /usr/local/lib $clucene_multiarch_libs"
if test "x$ac_static_clucene" = "xYES"; then
SEARCH_LIBS="libclucene.a";
@@ -40,13 +41,24 @@ fi
AC_CACHE_VAL(ac_cv_clucene_libdir, AC_FIND_FILE($SEARCH_LIBS, $ac_clucene_library_dirs, ac_cv_clucene_libdir))
if test "x$ac_cv_clucene_libdir" = "xNO"; then
- AC_MSG_ERROR(CLucene library not found. Try to use configure with --with-clucene-dir=/path/to/clucene);
+ AC_MSG_CHECKING([for CLucene 2.x library files])
+ SEARCH_LIBS="libclucene-shared.so libclucene-shared.so.1";
+ AC_CACHE_VAL(ac_cv_clucene2_libdir, AC_FIND_FILE($SEARCH_LIBS, $ac_clucene_library_dirs, ac_cv_clucene_libdir))
+
+ if test "x$ac_cv_clucene2_libdir" = "xNO"; then
+ AC_MSG_ERROR(CLucene library not found. Try to use configure with --with-clucene-dir=/path/to/clucene);
+ fi
fi
if test "x$ac_static_clucene" = "xYES"; then
LIB_CLUCENE="$ac_cv_clucene_libdir/libclucene.a";
else
- LIB_CLUCENE="-lclucene";
+ if test "x$ac_cv_clucene2_libdir" = "xNO"; then
+ LIB_CLUCENE="-lclucene";
+ else
+ CXXFLAGS="$CXXFLAGS -DCLUCENE_V2"
+ LIB_CLUCENE="-lclucene-shared";
+ fi
fi
AC_SUBST(CLUCENE_LIBRARY_PATH)