Exemplo n.º 1
0
QStringList ZefaniaLex::getAllKeys()
{
    if(!m_entryList.isEmpty()) {
        return m_entryList;
    }
    try {
        if(!hasIndex()) {
            if(buildIndex() != 0) {
                return QStringList();
            }
        }
        const QString index = indexPath();
        IndexReader* reader = IndexReader::open(index.toStdString().c_str());
        QStringList ret;
        for(int i = 0; i < reader->numDocs(); i++) {
            Document doc;
            reader->document(i, doc);

            ret.append(SearchTools::toQString(doc.get(_T("key"))));
        }
        m_entryList = ret;
        return ret;
    }
    catch(CLuceneError &err) {
        myWarning() << "clucene error = " << err.what();
        return QStringList();

    }
    catch(...) {
        return QStringList();
    }
}
Exemplo n.º 2
0
QStringList ZefaniaLex::getAllKeys()
{
    try {
        if(!hasIndex()) {
            if(buildIndex() != 0) {
                return QStringList();
            }
        }
        const QString index = indexPath();
        IndexReader* reader = IndexReader::open(index.toStdString().c_str());
        QStringList ret;
        for(int i = 0; i < reader->numDocs(); i++) {
            Document doc;
            reader->document(i, doc);
    #ifdef OBV_USE_WSTRING
            ret.append(QString::fromWCharArray(doc.get(_T("key"))));
    #else
            ret.append(QString::fromUtf16((const ushort*)doc.get(_T("key"))));
    #endif
        }
        return ret;
    }
    catch(...)
    {
        return QStringList();
    }
}
Exemplo n.º 3
0
void
indexdump(const char* dir) {
    IndexReader* indexreader = IndexReader::open(dir);
    int32_t max = indexreader->maxDoc();
    for (int i=0; i<max; ++i) {
        Document* doc = indexreader->document(i);
        if (doc) {
            docdump(doc);
        }
    }
    TermEnum* terms = indexreader->terms();
    Term* t = 0;
    while (terms->next()) {
        t = terms->term();
        printf("%s: %s\n", t2a(t->field()).c_str(), t2a(t->text()).c_str());
        _CLDECDELETE(t);
    }
}