PageRenderTime 24ms CodeModel.GetById 16ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/src/libtomahawk/database/fuzzyindex.h

Relevant Search: With Applications for Solr and Elasticsearch

For more in depth reading about search, ranking and generally everything you could ever want to know about how lucene, elasticsearch or solr work under the hood I highly suggest this book. Easily one of the most interesting technical books I have read in a long time. If you are tasked with solving search relevance problems even if not in Solr or Elasticsearch it should be your first reference. Amazon Affiliate Link
http://github.com/tomahawk-player/tomahawk
C++ Header | 88 lines | 56 code | 15 blank | 17 comment | 0 complexity | ec17a1e8e13a927d075455b9fa06dd3b MD5 | raw file
 1/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
 2 * 
 3 *   Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
 4 *
 5 *   Tomahawk is free software: you can redistribute it and/or modify
 6 *   it under the terms of the GNU General Public License as published by
 7 *   the Free Software Foundation, either version 3 of the License, or
 8 *   (at your option) any later version.
 9 *
10 *   Tomahawk is distributed in the hope that it will be useful,
11 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 *   GNU General Public License for more details.
14 *
15 *   You should have received a copy of the GNU General Public License
16 *   along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef FUZZYINDEX_H
20#define FUZZYINDEX_H
21
22#include <QObject>
23#include <QMap>
24#include <QHash>
25#include <QString>
26#include <QMutex>
27
28#include "Query.h"
29
30namespace lucene
31{
32    namespace analysis
33    {
34      class SimpleAnalyzer;
35    }
36    namespace store
37    {
38      class Directory;
39    }
40    namespace index
41    {
42      class IndexReader;
43      class IndexWriter;
44    }
45    namespace search
46    {
47      class IndexSearcher;
48    }
49}
50
51class DatabaseImpl;
52
53class FuzzyIndex : public QObject
54{
55Q_OBJECT
56
57public:
58    explicit FuzzyIndex( QObject* parent, bool wipe = false );
59    ~FuzzyIndex();
60
61    void beginIndexing();
62    void endIndexing();
63    void appendFields( const QMap< unsigned int, QMap< QString, QString > >& trackData );
64
65signals:
66    void indexReady();
67
68public slots:
69    void loadLuceneIndex();
70
71    QMap< int, float > search( const Tomahawk::query_ptr& query );
72    QMap< int, float > searchAlbum( const Tomahawk::query_ptr& query );
73
74private slots:
75    void updateIndex();
76    bool wipeIndex();
77
78private:
79    QMutex m_mutex;
80    QString m_lucenePath;
81
82    lucene::analysis::SimpleAnalyzer* m_analyzer;
83    lucene::store::Directory* m_luceneDir;
84    lucene::index::IndexReader* m_luceneReader;
85    lucene::search::IndexSearcher* m_luceneSearcher;
86};
87
88#endif // FUZZYINDEX_H