00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef INDRI_QUERYENVIRONMENT_HPP
00020 #define INDRI_QUERYENVIRONMENT_HPP
00021
00022 #include "indri/ScoredExtentResult.hpp"
00023 #include "indri/QueryServer.hpp"
00024 #include "indri/NetworkStream.hpp"
00025 #include "indri/NetworkMessageStream.hpp"
00026 #include "indri/Parameters.hpp"
00027 #include "indri/PriorFactory.hpp"
00028 #include "indri/ParsedDocument.hpp"
00029 #include "indri/Repository.hpp"
00030 #include "indri/QueryAnnotation.hpp"
00031
00040 class QueryEnvironment {
00041 private:
00042 std::vector<QueryServer*> _servers;
00043
00044 std::vector<Repository*> _repositories;
00045 std::vector<NetworkStream*> _streams;
00046 std::vector<NetworkMessageStream*> _messageStreams;
00047
00048 Parameters _parameters;
00049 PriorFactory _priorFactory;
00050
00051 void _mergeQueryResults( InferenceNetwork::MAllResults& results, std::vector<QueryServerResponse*>& responses );
00052 void _copyStatistics( std::vector<indri::lang::RawScorerNode*>& scorerNodes, InferenceNetwork::MAllResults& statisticsResults );
00053
00054 std::vector<QueryServerResponse*> _runServerQuery( std::vector<indri::lang::Node*>& roots, int resultsRequested );
00055 void _sumServerQuery( InferenceNetwork::MAllResults& results, std::vector<indri::lang::Node*>& roots, int resultsRequested );
00056 void _mergeServerQuery( InferenceNetwork::MAllResults& results, std::vector<indri::lang::Node*>& roots, int resultsRequested );
00057 void _annotateQuery( InferenceNetwork::MAllResults& results, const std::vector<DOCID_T>& documentIDs, std::string& annotatorName, indri::lang::Node* queryRoot );
00058
00059 std::vector<ScoredExtentResult> _runQuery( InferenceNetwork::MAllResults& results,
00060 const std::string& q,
00061 int resultsRequested,
00062 const std::vector<DOCID_T>* documentIDs,
00063 QueryAnnotation** annotation );
00064 void _scoredQuery( InferenceNetwork::MAllResults& results, indri::lang::Node* queryRoot, std::string& accumulatorName, int resultsRequested, const std::vector<DOCID_T>* documentSet );
00065
00066 QueryEnvironment( QueryEnvironment& other ) {}
00067
00068 public:
00069 QueryEnvironment();
00070 ~QueryEnvironment();
00073 void setMemory( UINT64 memory );
00076 void setScoringRules( const std::vector<std::string>& rules );
00079 void setStopwords( const std::vector<std::string>& stopwords );
00082 void addServer( const std::string& hostname );
00085 void addIndex( const std::string& pathname );
00087 void close();
00092 std::vector<ScoredExtentResult> runQuery( const std::string& query, int resultsRequested );
00093
00094 std::vector<ScoredExtentResult> runQuery( const std::string& query, const std::vector<DOCID_T>& documentSet, int resultsRequested );
00095
00100 QueryAnnotation* runAnnotatedQuery( const std::string& query, int resultsRequested );
00101
00102 QueryAnnotation* runAnnotatedQuery( const std::string& query, const std::vector<DOCID_T>& documentSet, int resultsRequested );
00103
00104
00109 std::vector<ParsedDocument*> documents( const std::vector<DOCID_T>& documentIDs );
00114 std::vector<ParsedDocument*> documents( const std::vector<ScoredExtentResult>& results );
00119 std::vector<std::string> documentMetadata( const std::vector<DOCID_T>& documentIDs, const std::string& attributeName );
00124 std::vector<std::string> documentMetadata( const std::vector<ScoredExtentResult>& documentIDs, const std::string& attributeName );
00127 INT64 termCount();
00131 INT64 termCount( const std::string& term );
00135 INT64 stemCount( const std::string& term );
00141 INT64 termFieldCount( const std::string& term, const std::string& field );
00147 INT64 stemFieldCount( const std::string& term, const std::string& field );
00150 std::vector<std::string> fieldList();
00153 INT64 documentCount();
00154 INT64 documentCount( const std::string& term );
00159 std::vector<DocumentVector*> documentVectors( const std::vector<DOCID_T>& documentIDs );
00160 };
00161
00162 #endif // INDRI_QUERYENVIRONMENT_HPP
00163