xref: /aosp_15_r20/external/icing/icing/result/snippet-context.h (revision 8b6cd535a057e39b3b86660c4aa06c99747c2136)
1 // Copyright (C) 2019 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_RESULT_SNIPPET_CONTEXT_H_
16 #define ICING_RESULT_SNIPPET_CONTEXT_H_
17 
18 #include "icing/proto/search.pb.h"
19 #include "icing/proto/term.pb.h"
20 #include "icing/query/query-terms.h"
21 
22 namespace icing {
23 namespace lib {
24 
25 // Stores data needed for snippeting. With SnippetContext we can fetch snippets
26 // for queries with multiple pages.
27 struct SnippetContext {
SnippetContextSnippetContext28   explicit SnippetContext(SectionRestrictQueryTermsMap query_terms_in,
29                           ResultSpecProto::SnippetSpecProto snippet_spec_in,
30                           TermMatchType::Code match_type_in)
31       : query_terms(std::move(query_terms_in)),
32         snippet_spec(std::move(snippet_spec_in)),
33         match_type(match_type_in) {}
34 
35   // Query terms that are used to find snippets
36   SectionRestrictQueryTermsMap query_terms;
37 
38   // Spec that defines some quantities of snippeting
39   ResultSpecProto::SnippetSpecProto snippet_spec;
40 
41   // Defines how we match each term
42   TermMatchType::Code match_type;
43 };
44 
45 }  // namespace lib
46 }  // namespace icing
47 
48 #endif  // ICING_RESULT_SNIPPET_CONTEXT_H_
49