Fix FTBFS with CLucene v2

r14.0.x
Timothy Pearson 11 years ago
parent 9962399a82
commit 9e9e51c2eb

@ -1 +1 @@
Subproject commit 39466b7b95f25a3e0f6da52b156b194b10cbac9d
Subproject commit c5cef804fe69e65e2e2f76df31fdbc7d4a4650e0

@ -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);

@ -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)

Loading…
Cancel
Save