aboutsummaryrefslogtreecommitdiff
path: root/icing/query/advanced_query_parser/query-visitor.h
diff options
context:
space:
mode:
authorTerry Wang <tytytyww@google.com>2023-01-23 14:54:45 -0800
committerTerry Wang <tytytyww@google.com>2023-01-23 14:54:45 -0800
commitcccafab8dfcae94d7072eb49ea971e3c688bdfc4 (patch)
treec5658335e3a0287ab3a7b25a3f18585920515f75 /icing/query/advanced_query_parser/query-visitor.h
parentec29b14d5a908748d6e0699df7c85842a95a7b3c (diff)
downloadicing-cccafab8dfcae94d7072eb49ea971e3c688bdfc4.tar.gz
Update Icing from upstream.
Descriptions: ====================================================================== Fix time complexity regression for snippet retriever ====================================================================== Add support for QueryTerms SectionRestrict Map in Advanced Query. ====================================================================== [NumericSearch][Storage][9/x] Create unit tests for AddKeys and GetIterator ====================================================================== [NumericSearch][Storage][8/x] Add options ====================================================================== Fix the stack overflow issue for icing advanced scoring/query parsers/visitors by limiting the number of tokens allowed ====================================================================== Improves the has joinspec check ====================================================================== Fix the bug of DocHitInfoIteratorTermMain found by monkey test ====================================================================== Rename tests defined in DestructibleDirectoryTest to include "directory" instead of "file". ====================================================================== Support projection in icing monkey test ====================================================================== [NumericSearch][Storage][7/x] Implement iterator for query ====================================================================== [NumericSearch][Storage][6/x] Implement AddKeys ====================================================================== Add support for relevance scoring by enabling term_frequency retrieval in DocHitInfoIterators and by populating the QueryTermIteratorsMap. ====================================================================== [JoinableCache][1/x] Compute SchemaDelta for joinable properties ====================================================================== [NumericSearch][Storage][5/x] PersistToDisk ====================================================================== [NumericSearch][Storage][4.1/x] Create unit tests for initialize ====================================================================== [NumericSearch][Storage][4.0/x] Implement Create and Initialize functions ====================================================================== Rename PostingListUsedSerializer related classes Bug: 193244409 Bug: 208654892 Bug: 246984163 Bug: 249829533 Bug: 256022027 Bug: 265258364 Bug: 265834832 Change-Id: Ibc7011a793ef5ed09eace0fb05d168adf5b4faca
Diffstat (limited to 'icing/query/advanced_query_parser/query-visitor.h')
-rw-r--r--icing/query/advanced_query_parser/query-visitor.h29
1 files changed, 27 insertions, 2 deletions
diff --git a/icing/query/advanced_query_parser/query-visitor.h b/icing/query/advanced_query_parser/query-visitor.h
index c6b7d8e..9e68572 100644
--- a/icing/query/advanced_query_parser/query-visitor.h
+++ b/icing/query/advanced_query_parser/query-visitor.h
@@ -23,6 +23,7 @@
#include "icing/absl_ports/canonical_errors.h"
#include "icing/index/index.h"
+#include "icing/index/iterator/doc-hit-info-iterator-filter.h"
#include "icing/index/iterator/doc-hit-info-iterator.h"
#include "icing/index/numeric/numeric-index.h"
#include "icing/query/advanced_query_parser/abstract-syntax-tree.h"
@@ -44,13 +45,18 @@ class QueryVisitor : public AbstractSyntaxTreeVisitor {
const DocumentStore* document_store,
const SchemaStore* schema_store,
const Normalizer* normalizer,
- TermMatchType::Code match_type)
+ DocHitInfoIteratorFilter::Options filter_options,
+ TermMatchType::Code match_type,
+ bool needs_term_frequency_info)
: index_(*index),
numeric_index_(*numeric_index),
document_store_(*document_store),
schema_store_(*schema_store),
normalizer_(*normalizer),
- match_type_(match_type) {}
+ filter_options_(std::move(filter_options)),
+ match_type_(match_type),
+ needs_term_frequency_info_(needs_term_frequency_info),
+ processing_not_(false) {}
void VisitFunctionName(const FunctionNameNode* node) override;
void VisitString(const StringNode* node) override;
@@ -166,9 +172,19 @@ class QueryVisitor : public AbstractSyntaxTreeVisitor {
libtextclassifier3::StatusOr<PendingValue> ProcessHasOperator(
const NaryOperatorNode* node);
+ // RETURNS:
+ // - the current property restrict or empty string if there is no property
+ // restrict.
+ // - INVALID_ARGUMENT if the current restrict is invalid (ie is a chain of
+ // restricts with different properties such as `subject:(body:foo)`).
+ libtextclassifier3::StatusOr<std::string> GetPropertyRestrict() const;
+
std::stack<PendingValue> pending_values_;
libtextclassifier3::Status pending_error_;
+ SectionRestrictQueryTermsMap property_query_terms_map_;
+
+ QueryTermIteratorsMap query_term_iterators_;
// Set of features invoked in the query.
std::unordered_set<Feature> features_;
@@ -178,7 +194,16 @@ class QueryVisitor : public AbstractSyntaxTreeVisitor {
const SchemaStore& schema_store_; // Does not own!
const Normalizer& normalizer_; // Does not own!
+ DocHitInfoIteratorFilter::Options filter_options_;
TermMatchType::Code match_type_;
+ // Whether or not term_frequency information is needed. This affects:
+ // - how DocHitInfoIteratorTerms are constructed
+ // - whether the QueryTermIteratorsMap is populated in the QueryResults.
+ bool needs_term_frequency_info_;
+
+ // The stack of property restricts currently being processed by the visitor.
+ std::vector<std::string> pending_property_restricts_;
+ bool processing_not_;
};
} // namespace lib