00001 /*========================================================================== 00002 * Copyright (c) 2004 University of Massachusetts. All Rights Reserved. 00003 * 00004 * Use of the Lemur Toolkit for Language Modeling and Information Retrieval 00005 * is subject to the terms of the software license set forth in the LICENSE 00006 * file included with this software, and also available at 00007 * http://www.lemurproject.org/license.html 00008 * 00009 *========================================================================== 00010 */ 00011 00012 00013 // 00014 // LocalQueryServer 00015 // 00016 // 15 March 2004 -- tds 00017 // 00018 // Allows a QueryEnvironment to run queries against a 00019 // local connection (without doing a network hop). 00020 // This is especially useful for testing. 00021 // 00022 00023 #ifndef INDRI_LOCALQUERYSERVER_HPP 00024 #define INDRI_LOCALQUERYSERVER_HPP 00025 00026 #include "indri/QueryServer.hpp" 00027 #include "indri/Collection.hpp" 00028 #include "indri/Repository.hpp" 00029 #include "indri/DocumentVector.hpp" 00030 #include "indri/ListCache.hpp" 00031 00032 class LocalQueryServer : public QueryServer { 00033 private: 00034 Repository& _repository; 00035 ListCache _cache; 00036 00037 public: 00038 LocalQueryServer( Repository& repository ); 00039 00040 // query 00041 QueryServerResponse* runQuery( std::vector<indri::lang::Node*>& roots, int resultsRequested, bool optimize ); 00042 00043 // single document queries 00044 ParsedDocument* document( int documentID ); 00045 std::string documentMetadatum( int documentID, const std::string& attributeName ); 00046 00047 // batch queries 00048 QueryServerDocumentsResponse* documents( const std::vector<int>& documentIDs ); 00049 QueryServerMetadataResponse* documentMetadata( const std::vector<int>& documentIDs, const std::string& attributeName ); 00050 00051 // terms 00052 INT64 termCount(); 00053 INT64 termCount( int term ); 00054 INT64 termCount( const std::string& term ); 00055 INT64 stemCount( const std::string& stem ); 00056 std::string termName( int term ); 00057 int termID( const std::string& term ); 00058 00059 // fields 00060 std::vector<std::string> fieldList(); 00061 INT64 termFieldCount( int term, const std::string& field ); 00062 INT64 termFieldCount( const std::string& term, const std::string& field ); 00063 INT64 stemFieldCount( const std::string& stem, const std::string& field ); 00064 00065 // documents 00066 int documentLength( int documentID ); 00067 INT64 documentCount(); 00068 INT64 documentCount( const std::string& term ); 00069 00070 // vector 00071 QueryServerVectorsResponse* documentVectors( const std::vector<int>& documentIDs ); 00072 }; 00073 00074 #endif // INDRI_LOCALQUERYSERVER_HPP