xref: /aosp_15_r20/external/icing/icing/query/query-results.h (revision 8b6cd535a057e39b3b86660c4aa06c99747c2136)
1 // Copyright (C) 2022 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef ICING_QUERY_QUERY_RESULTS_H_
16 #define ICING_QUERY_QUERY_RESULTS_H_
17 
18 #include <memory>
19 #include <unordered_set>
20 
21 #include "icing/index/embed/embedding-query-results.h"
22 #include "icing/index/iterator/doc-hit-info-iterator.h"
23 #include "icing/query/query-features.h"
24 #include "icing/query/query-terms.h"
25 
26 namespace icing {
27 namespace lib {
28 
29 struct QueryResults {
30   std::unique_ptr<DocHitInfoIterator> root_iterator;
31   // A map from section names to sets of terms restricted to those sections.
32   // Query terms that are not restricted are found at the entry with key "".
33   SectionRestrictQueryTermsMap query_terms;
34   // Hit iterators for the text terms in the query. These query_term_iterators
35   // are completely separate from the iterators that make the iterator tree
36   // beginning with root_iterator.
37   // This will only be populated when ranking_strategy == RELEVANCE_SCORE.
38   QueryTermIteratorsMap query_term_iterators;
39   // Contains similarity scores from embedding based queries, which will be used
40   // in the advanced scoring language to determine the results for the
41   // "this.matchedSemanticScores(...)" function.
42   EmbeddingQueryResults embedding_query_results;
43   // Features that are invoked during query execution.
44   // The list of possible features is defined in query_features.h.
45   std::unordered_set<Feature> features_in_use;
46 };
47 
48 }  // namespace lib
49 }  // namespace icing
50 
51 #endif  // ICING_QUERY_QUERY_RESULTS_H_
52