1// Copyright 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
15syntax = "proto2";
16
17package icing.lib;
18
19option java_package = "com.google.android.icing.proto";
20option java_multiple_files = true;
21option objc_class_prefix = "ICNG";
22
23// Encapsulates the configurations on how Icing should score and rank the search
24// results.
25// TODO(b/170347684): Change all timestamps to seconds.
26// Next tag: 3
27message ScoringSpecProto {
28  // OPTIONAL: Indicates how the search results will be ranked.
29  message RankingStrategy {
30    enum Code {
31      // No ranking strategy specified, documents may be returned in an
32      // arbitrary order.
33      NONE = 0;
34
35      // Ranked by user-provided document scores.
36      DOCUMENT_SCORE = 1;
37
38      // Ranked by document creation timestamps.
39      CREATION_TIMESTAMP = 2;
40
41      // The following ranking strategies are based on usage reporting. Please
42      // see usage.proto for more information. If one of the usage ranking
43      // strategy is used but none of result documents have reported usage, the
44      // documents will be returned in the default reverse insertion order.
45
46      // Ranked by count of reports with usage type 1.
47      USAGE_TYPE1_COUNT = 3;
48
49      // Ranked by count of reports with usage type 2.
50      USAGE_TYPE2_COUNT = 4;
51
52      // Ranked by count of reports with usage type 3.
53      USAGE_TYPE3_COUNT = 5;
54
55      // Ranked by last used timestamp with usage type 1. The timestamps are
56      // compared in seconds.
57      USAGE_TYPE1_LAST_USED_TIMESTAMP = 6;
58
59      // Ranked by last used timestamp with usage type 2. The timestamps are
60      // compared in seconds.
61      USAGE_TYPE2_LAST_USED_TIMESTAMP = 7;
62
63      // Ranked by last used timestamp with usage type 3. The timestamps are
64      // compared in seconds.
65      USAGE_TYPE3_LAST_USED_TIMESTAMP = 8;
66
67      // Ranked by relevance score, currently computed as BM25F score.
68      RELEVANCE_SCORE = 9;
69    }
70  }
71  optional RankingStrategy.Code rank_by = 1;
72
73  // OPTIONAL: Indicates the order of returned search results, the default is
74  // DESC, meaning that results with higher scores come first. This order field
75  // will be ignored if 'rank_by' is NONE.
76  message Order {
77    enum Code {
78      // Search results will be returned in a descending order.
79      DESC = 0;
80
81      // Search results will be returned in a ascending order.
82      ASC = 1;
83    }
84  }
85  optional Order.Code order_by = 2;
86}
87