/***************************************************************************
 *   Copyright (C) 2005 by xavier helluy   *
 *   xavier.helluy@web.de   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA.             *
 ***************************************************************************/
#ifndef KCLUCENETHREAD_H
#define KCLUCENETHREAD_H


#include "searchthread.h"
#include "kclucenedaemon.h"

#include <CLucene.h>
#include <CLucene/index/IndexReader.h>
#include <CLucene/index/IndexWriter.h>
#include <CLucene/index/Term.h>
#include <CLucene/document/Document.h>
#include <CLucene/document/Field.h>
#include <CLucene/document/DateField.h>
#include <CLucene/store/Directory.h>
#include <CLucene/store/FSDirectory.h>
#include <CLucene/queryParser/QueryParser.h>
#include <CLucene/analysis/standard/StandardAnalyzer.h>
#include <CLucene/analysis/Analyzers.h>
#include <CLucene/search/IndexSearcher.h>
#include <CLucene/search/MultiSearcher.h>
#include <CLucene/analysis/standard/StandardAnalyzer.h>
/**
@author xavier helluy
*/
typedef lucene::search::Searcher * pointerToSearcher;

class KCLuceneThread : public SearchThread
{
	public:
		KCLuceneThread(QObject * o , const QString & str , QString  socketPath ,
			  QDict <ClientList> * QueryList ,
			  KCLuceneDaemon kclucenedaemon,
			  QStringList indexesPathList,
			  const bool &peer2peer );
		
    		~KCLuceneThread();

		//thread stuff
    		void run();
		
		void runMultiIndexQuery(bool);
		void setIndexesPathList(QStringList indexList);
		void encodeHits( lucene::search::Hits * h );
		
		QStringList                            m_indexesPathList;
		
	private:
		QDict <lucene::search::IndexSearcher>  m_indexSingleSearchersList;
		QDict <QStringList   >                 m_indexMultiSearchersList;
};

#endif
