strus  0.17
queryInterface.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 Patrick P. Frey
3  *
4  * This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7  */
10 #ifndef _STRUS_QUERY_INTERFACE_HPP_INCLUDED
11 #define _STRUS_QUERY_INTERFACE_HPP_INCLUDED
14 #include "strus/queryResult.hpp"
15 #include "strus/numericVariant.hpp"
16 #include "strus/termStatistics.hpp"
18 #include <string>
19 #include <vector>
20 #include <utility>
21 #include <iostream>
22 
23 namespace strus {
24 
26 class PostingJoinOperatorInterface;
27 
30 {
31 public:
33  virtual ~QueryInterface(){}
34 
39  virtual void pushTerm(
40  const std::string& type_,
41  const std::string& value_,
42  const Index& length_)=0;
43 
48  virtual void pushDocField(
49  const std::string& metadataRangeStart,
50  const std::string& metadataRangeEnd)=0;
51 
58  virtual void pushExpression(
59  const PostingJoinOperatorInterface* operation,
60  unsigned int argc, int range, unsigned int cardinality)=0;
61 
67  virtual void attachVariable( const std::string& name_)=0;
68 
72  virtual void defineFeature( const std::string& set_, double weight_=1.0)=0;
73 
78  virtual void defineTermStatistics(
79  const std::string& type_,
80  const std::string& value_,
81  const TermStatistics& stats_)=0;
82 
85  virtual void defineGlobalStatistics(
86  const GlobalStatistics& stats_)=0;
87 
97  const std::string& name,
98  const NumericVariant& operand,
99  bool newGroup=true)=0;
100 
103  virtual void addDocumentEvaluationSet(
104  const std::vector<Index>& docnolist_)=0;
105 
108  virtual void addAccess( const std::string& username_)=0;
109 
112  virtual void setMaxNofRanks( std::size_t maxNofRanks_)=0;
115  virtual void setMinRank( std::size_t minRank_)=0;
116 
120  virtual void setWeightingVariableValue( const std::string& name, double value)=0;
121 
124  virtual void setDebugMode( bool debug)=0;
125 
128  virtual QueryResult evaluate() const=0;
129 
132  virtual std::string tostring() const=0;
133 };
134 
135 }//namespace
136 #endif
Result of a query evaluation.
int32_t Index
Number type generally used for locally counted indices.
Definition: index.hpp:29
virtual void defineGlobalStatistics(const GlobalStatistics &stats_)=0
Define the global statistics for the case that they are defined by the client.
virtual void addAccess(const std::string &username_)=0
Add a restriction for documents accessible by this query.
virtual void setMaxNofRanks(std::size_t maxNofRanks_)=0
Set the maximum number of ranks to evaluate starting with the minimum rank.
Client interface for accessing a storage (read/write)
virtual void setMinRank(std::size_t minRank_)=0
Set the minimum rank number to return.
virtual void pushDocField(const std::string &metadataRangeStart, const std::string &metadataRangeEnd)=0
Push an expression on the query stack that defines a single field per document. The fields are repres...
virtual void setWeightingVariableValue(const std::string &name, double value)=0
Set the value of a variable in the weigthing formula defined with QueryEval::defineWeightingFormula(S...
virtual void addMetaDataRestrictionCondition(const MetaDataRestrictionInterface::CompareOperator &opr, const std::string &name, const NumericVariant &operand, bool newGroup=true)=0
Add a condition clause to the restriction on the document meta data of this query.
Defines a strus information retrieval query.
Definition: queryInterface.hpp:29
virtual void addDocumentEvaluationSet(const std::vector< Index > &docnolist_)=0
Define a restriction on the documents as list of local document numbers (Add local document numbers t...
virtual ~QueryInterface()
Destructor.
Definition: queryInterface.hpp:33
virtual void defineFeature(const std::string &set_, double weight_=1.0)=0
Define the topmost element of the stack as feature, removing it from the stack.
virtual void pushTerm(const std::string &type_, const std::string &value_, const Index &length_)=0
Push a term to the query stack.
virtual void pushExpression(const PostingJoinOperatorInterface *operation, unsigned int argc, int range, unsigned int cardinality)=0
Push an expression formed by the topmost elements from the stack to the query stack, removing the argument elements.
virtual void attachVariable(const std::string &name_)=0
Attaches a variable to the top expression or term on the query stack.
Global term statistics, if passed down with the query.
Definition: termStatistics.hpp:16
CompareOperator
Comparison operator for restrictions.
Definition: metaDataRestrictionInterface.hpp:29
Global document statistics, if passed down with the query.
Definition: globalStatistics.hpp:16
virtual QueryResult evaluate() const =0
Evaluate the query.
virtual void defineTermStatistics(const std::string &type_, const std::string &value_, const TermStatistics &stats_)=0
Define the statistics of a term for the case that they are defined by the client (for example in a sy...
Structure defining the result of a strus query.
Definition: queryResult.hpp:22
Interface for creating iterators on joined sets of postings.
Definition: postingJoinOperatorInterface.hpp:23
virtual std::string tostring() const =0
Map query to readable string.
virtual void setDebugMode(bool debug)=0
Switch debug mode on or off (default off). In case of debug mode additional attributes defined with t...