Docs Menu
Docs Home
/
MongoDB Atlas
/ / / /

점수 상세 정보 반환

이 페이지의 내용

  • 구문
  • 옵션
  • 출력
  • 점수에 기여하는 요소
  • 예시
  • 연산자 예제
  • 사용자 지정 점수 예시

$search 단계에서 scoreDetails 부울 옵션을 사용하면 쿼리 결과의 각 문서에 대한 점수를 자세히 분석할 수 있습니다. 메타데이터를 보려면 $project 단계에서 $meta 표현식을 사용해야 합니다.

{
"$search": {
"<operator>": {
<operator-specification>
},
"scoreDetails": true | false
}
},
{
"$project": {
"scoreDetails": {"$meta": "searchScoreDetails"}
}
}

$search 단계 에서 scoreDetails 부울 옵션은 다음 값 중 하나를 사용합니다.

  • true - 결과에 문서의 점수 세부 정보를 포함합니다. true로 설정하면 Atlas Search는 결과에 있는 각 문서의 점수를 자세히 분석하여 반환합니다. 자세한 내용은 출력을 참조하세요.

  • false - 결과에서 점수 분석의 세부 정보를 제외합니다. (기본값)

생략하면 scoreDetails 옵션의 기본값은 false 입니다.

$project 단계에서 scoreDetails 필드는 $meta 표현식을 취하며, 이는 다음 값을 요구합니다:

searchScoreDetails

결과에 포함된 각 문서의 점수에 대한 자세한 분석을 반환합니다.

scoreDetails 옵션은 결과의 각 문서에 대해 scoreDetails 객체 내부의 details 배열에 다음 필드를 반환합니다.

필드
유형
설명

value

float

점수 산정 공식의 하위 세트에 의한 점수 기여도. 최상위 value는 결과 문서의 전체 점수를 표시하며 $searchScore 값과 같습니다.

점수 산정 공식은 쿼리에 사용된 연산자에 따라 달라집니다. 예를 들어, Atlas Search는 textnear 연산자가 포함된 compound 쿼리에 대해 다음과 같은 점수 산정 공식을 사용합니다. BM25Similarity + distance decay function

description

문자열

문서에 점수를 매긴 방법과 점수 계산 시 고려된 요소에 대한 정보를 포함하는 채점 공식의 하위 집합입니다. 최상위 description은 문서의 점수를 매기는 데 사용된 전체 점수 공식을 보여줍니다.

자세한 학습 점수에 영향을 미치는 요인을 참조하세요.

details

객체 배열

점수 공식의 하위 집합을 기반으로 문서에 있는 각 일치 항목의 점수 분석입니다. 이 값은 구조가 재귀적인 점수 세부 정보 객체의 배열입니다.

BM25Similarity 의 경우, 점수는 boost * idf * tf 로 계산됩니다. Atlas Search는 점수를 계산할 때 다음 BM25Similarity 요소를 고려합니다.

boost

텀의 중요도를 높입니다.

freq

쿼리 텀의 빈도입니다.

idf

쿼리의 역 문서 빈도입니다. Atlas Search는 다음 공식을 사용하여 빈도를 계산합니다.

log(1 + (N - n + 0.5) / (n + 0.5))

where:

  • N 는 필드가 있는 총 문서 수입니다.

  • n 는 해당 텀을 포함하는 문서 수입니다.

tf

용어 빈도. Atlas Search는 다음 공식을 사용하여 빈도를 계산합니다.

freq / (freq + k1 * (1 - b + b * dl / avgdl))

where:

  • freq 는 텀 내에서 해당 문서의 발생 횟수입니다.

  • k1 은(는) 내부적으로 지정된 텀 포화 매개변수입니다. 텀이 다시 발생할 때마다 점수가 얼마나 증가하는지에 영향을 줍니다.

  • avgdl 모든 문서에서 필드의 평균 길이입니다.

  • dl 은 문서에 있는 필드의 길이입니다.

  • b 는 내부적으로도 설정되는 길이 정규화 매개변수입니다. bdlavgdl 의 비율을 곱합니다. b 이 증가하면 dlavgdl 의 비율의 효과가 증폭됩니다.

거리 감쇠 함수의 경우 점수는 pivot / (pivot + abs(fieldValue - origin)) 으로 계산됩니다. Atlas Search는 점수를 계산할 때 다음 요소를 고려합니다.

origin

근처에서 검색할 값입니다. 이는 결과의 근접성이 측정되는 점입니다.

fieldValue

문서에서 쿼리하는 필드의 값입니다. fieldValueorigin 에 가까울수록 근거리 쿼리의 점수가 높습니다.

pivot

fieldValueorigin 사이의 거리가 동일한 경우 점수를 0.5 과 동일하게 만들기 위한 참고 점으로 지정된 값입니다. 이는 fieldValueorigin 사이의 거리가 멀수록 점수가 얼마나 빨리 감소하는지 정의합니다. fieldValueorigin 사이의 주어진 거리에서 pivot 이 감소하면 점수도 감소합니다.

다음 예에서는 다음에 대한 결과에서 점수의 세부 정보를 검색하는 방법을 보여 줍니다.

객체 배열에서 재귀적으로 점수의 세부 정보를 보려면 다음을 실행하여 mongosh 에서 설정을 구성합니다.

config.set('inspectDepth', Infinity)

다음 예제에서는 텍스트 , near , 복합 embeddedDocument 연산자 쿼리에 대한 결과의 문서에 대해 옵션을 사용하여 점수 분석을 검색하는 방법을 보여 줍니다.$search scoreDetails

다음 예제에서는 텍스트 연산자를 사용하여 sample_mflix.movies 컬렉션의 title 필드에서 용어 autumn을 쿼리합니다. 이 쿼리는 $search 단계에서 scoreDetails 옵션을 지정하여 결과에 있는 각 문서의 점수에 대한 자세한 분석을 조회합니다. 이 쿼리는 $limit 단계를 사용하여 결과를 문서 세 개로 제한하고 $project 단계를 사용하여 다음을 수행합니다.

  • _id 필드를 제외합니다.

  • title 필드만 포함합니다.

  • 결과에 score 필드를 추가하여 문서의 점수를 반환하고 scoreDetails 필드를 추가하여 문서의 점수에 대한 자세한 분석을 반환합니다.

1db.movies.aggregate([
2 {
3 "$search": {
4 "text": {
5 "path": "title",
6 "query": "autumn"
7 },
8 "scoreDetails": true
9 }
10 },
11 {
12 "$limit": 3
13 },
14 {
15 "$project": {
16 "_id": 0,
17 "title": 1,
18 "score": { "$meta": "searchScore" },
19 "scoreDetails": { "$meta": "searchScoreDetails" }
20 }
21 }
22])
1[
2 {
3 title: 'Autumn Leaves',
4 score: 3.834893226623535,
5 scoreDetails: {
6 value: 3.834893226623535,
7 description: '$type:string/title:autumn [BM25Similarity], result of:',
8 details: [
9 {
10 value: 3.834893226623535,
11 description: 'score(freq=1.0), computed as boost * idf * tf from:',
12 details: [
13 {
14 value: 7.39188289642334,
15 description: 'idf, computed as log(1 + (N - n + 0.5) / (n + 0.5)) from:',
16 details: [
17 {
18 value: 14,
19 description: 'n, number of documents containing term',
20 details: []
21 },
22 {
23 value: 23529,
24 description: 'N, total number of documents with field',
25 details: []
26 }
27 ]
28 },
29 {
30 value: 0.5187978744506836,
31 description: 'tf, computed as freq / (freq + k1 * (1 - b + b * dl / avgdl)) from:',
32 details: [
33 {
34 value: 1,
35 description: 'freq, occurrences of term within document',
36 details: []
37 },
38 {
39 value: 1.2000000476837158,
40 description: 'k1, term saturation parameter',
41 details: []
42 },
43 {
44 value: 0.75,
45 description: 'b, length normalization parameter',
46 details: []
47 },
48 {
49 value: 2,
50 description: 'dl, length of field',
51 details: []
52 },
53 {
54 value: 2.868375301361084,
55 description: 'avgdl, average length of field',
56 details: []
57 }
58 ]
59 }
60 ]
61 }
62 ]
63 }
64 },
65 {
66 title: 'Late Autumn',
67 score: 3.834893226623535,
68 scoreDetails: {
69 value: 3.834893226623535,
70 description: '$type:string/title:autumn [BM25Similarity], result of:',
71 details: [
72 {
73 value: 3.834893226623535,
74 description: 'score(freq=1.0), computed as boost * idf * tf from:',
75 details: [
76 {
77 value: 7.39188289642334,
78 description: 'idf, computed as log(1 + (N - n + 0.5) / (n + 0.5)) from:',
79 details: [
80 {
81 value: 14,
82 description: 'n, number of documents containing term',
83 details: []
84 },
85 {
86 value: 23529,
87 description: 'N, total number of documents with field',
88 details: []
89 }
90 ]
91 },
92 {
93 value: 0.5187978744506836,
94 description: 'tf, computed as freq / (freq + k1 * (1 - b + b * dl / avgdl)) from:',
95 details: [
96 {
97 value: 1,
98 description: 'freq, occurrences of term within document',
99 details: []
100 },
101 {
102 value: 1.2000000476837158,
103 description: 'k1, term saturation parameter',
104 details: []
105 },
106 {
107 value: 0.75,
108 description: 'b, length normalization parameter',
109 details: []
110 },
111 {
112 value: 2,
113 description: 'dl, length of field',
114 details: []
115 },
116 {
117 value: 2.868375301361084,
118 description: 'avgdl, average length of field',
119 details: []
120 }
121 ]
122 }
123 ]
124 }
125 ]
126 }
127 },
128 {
129 title: 'Cheyenne Autumn',
130 score: 3.834893226623535,
131 scoreDetails: {
132 value: 3.834893226623535,
133 description: '$type:string/title:autumn [BM25Similarity], result of:',
134 details: [
135 {
136 value: 3.834893226623535,
137 description: 'score(freq=1.0), computed as boost * idf * tf from:',
138 details: [
139 {
140 value: 7.39188289642334,
141 description: 'idf, computed as log(1 + (N - n + 0.5) / (n + 0.5)) from:',
142 details: [
143 {
144 value: 14,
145 description: 'n, number of documents containing term',
146 details: []
147 },
148 {
149 value: 23529,
150 description: 'N, total number of documents with field',
151 details: []
152 }
153 ]
154 },
155 {
156 value: 0.5187978744506836,
157 description: 'tf, computed as freq / (freq + k1 * (1 - b + b * dl / avgdl)) from:',
158 details: [
159 {
160 value: 1,
161 description: 'freq, occurrences of term within document',
162 details: []
163 },
164 {
165 value: 1.2000000476837158,
166 description: 'k1, term saturation parameter',
167 details: []
168 },
169 {
170 value: 0.75,
171 description: 'b, length normalization parameter',
172 details: []
173 },
174 {
175 value: 2,
176 description: 'dl, length of field',
177 details: []
178 },
179 {
180 value: 2.868375301361084,
181 description: 'avgdl, average length of field',
182 details: []
183 }
184 ]
185 }
186 ]
187 }
188 ]
189 }
190 }
191]

Atlas Search는 점수를 계산할 때 다음 BM25Similarity 요소를 고려합니다.

boost

텀의 중요도를 높입니다.

freq

쿼리 텀의 빈도입니다.

idf

쿼리의 역 문서 빈도입니다. Atlas Search는 다음 공식을 사용하여 빈도를 계산합니다.

log(1 + (N - n + 0.5) / (n + 0.5))

where:

  • N 는 필드가 있는 총 문서 수입니다.

  • n 는 해당 텀을 포함하는 문서 수입니다.

tf

용어 빈도. Atlas Search는 다음 공식을 사용하여 빈도를 계산합니다.

freq / (freq + k1 * (1 - b + b * dl / avgdl))

where:

  • freq 는 텀 내에서 해당 문서의 발생 횟수입니다.

  • k1 은(는) 내부적으로 지정된 텀 포화 매개변수입니다. 텀이 다시 발생할 때마다 점수가 얼마나 증가하는지에 영향을 줍니다.

  • avgdl 모든 문서에서 필드의 평균 길이입니다.

  • dl 은 문서에 있는 필드의 길이입니다.

  • b 는 내부적으로도 설정되는 길이 정규화 매개변수입니다. bdlavgdl 의 비율을 곱합니다. b 이 증가하면 dlavgdl 의 비율의 효과가 증폭됩니다.

다음 예시에서는 near 연산자를 사용하여 sample_mflix.movies 컬렉션의 released 필드를 쿼리하여 2010년 1월 01일 즈음에 개봉된 영화를 찾습니다. 이 쿼리는 결과에 있는 각 문서의 점수에 대한 자세한 분석을 검색하기 위해 $search 단계에서 scoreDetails 옵션을 지정합니다. 이 쿼리는 $limit 단계를 사용하여 결과를 3개 문서로 제한하고 $project 단계를 사용하여 다음을 수행합니다.

  • _id 필드를 제외합니다.

  • titlereleased 필드만 포함합니다.

  • 결과에 score 필드를 추가하여 문서의 점수를 반환하고 scoreDetails 필드를 추가하여 문서의 점수에 대한 자세한 분석을 반환합니다.

1db.movies.aggregate([
2 {
3 "$search": {
4 "near": {
5 "path": "released",
6 "origin": ISODate("2010-01-01T00:00:00.000+00:00"),
7 "pivot": 7776000000
8 },
9 "scoreDetails": true
10 }
11 },
12 {
13 "$limit": 3
14 },
15 {
16 "$project": {
17 "_id": 0,
18 "title": 1,
19 "released": 1,
20 "score": { "$meta": "searchScore" },
21 "scoreDetails": { "$meta": "searchScoreDetails" }
22 }
23 }
24])
1[
2 {
3 title: 'Tony',
4 released: ISODate("2010-01-01T00:00:00.000Z"),
5 score: 1,
6 scoreDetails: {
7 value: 1,
8 description: 'Distance score, computed as weight * pivotDistance / (pivotDistance + abs(value - origin)) from:',
9 details: [
10 { value: 1, description: 'weight', details: [] },
11 {
12 value: 7776000000,
13 description: 'pivotDistance',
14 details: []
15 },
16 { value: 1262303969280, description: 'origin', details: [] },
17 {
18 value: 1262303969280,
19 description: 'current value',
20 details: []
21 }
22 ]
23 }
24 },
25 {
26 title: 'And Everything Is Going Fine',
27 released: ISODate("2010-01-01T00:00:00.000Z"),
28 score: 1,
29 scoreDetails: {
30 value: 1,
31 description: 'Distance score, computed as weight * pivotDistance / (pivotDistance + abs(value - origin)) from:',
32 details: [
33 { value: 1, description: 'weight', details: [] },
34 {
35 value: 7776000000,
36 description: 'pivotDistance',
37 details: []
38 },
39 { value: 1262303969280, description: 'origin', details: [] },
40 {
41 value: 1262303969280,
42 description: 'current value',
43 details: []
44 }
45 ]
46 }
47 },
48 {
49 title: 'A Film with Me in It',
50 released: ISODate("2010-01-01T00:00:00.000Z")
51 score: 1,
52 scoreDetails: {
53 value: 1,
54 description: 'Distance score, computed as weight * pivotDistance / (pivotDistance + abs(value - origin)) from:',
55 details: [
56 { value: 1, description: 'weight', details: [] },
57 {
58 value: 7776000000,
59 description: 'pivotDistance',
60 details: []
61 },
62 { value: 1262303969280, description: 'origin', details: [] },
63 {
64 value: 1262303969280,
65 description: 'current value',
66 details: []
67 }
68 ]
69 }
70 }
71]

거리 점수의 경우, Atlas Search는 점수를 계산하기 위해 다음과 같은 요소를 고려합니다.

origin

근처에서 검색할 값입니다. 이는 결과의 근접성이 측정되는 점입니다.

fieldValue

문서에서 쿼리하는 필드의 값입니다. fieldValueorigin 에 가까울수록 근거리 쿼리의 점수가 높습니다.

pivot

fieldValueorigin 사이의 거리가 동일한 경우 점수를 0.5 과 동일하게 만들기 위한 참고 점으로 지정된 값입니다. 이는 fieldValueorigin 사이의 거리가 멀수록 점수가 얼마나 빨리 감소하는지 정의합니다. fieldValueorigin 사이의 주어진 거리에서 pivot 이 감소하면 점수도 감소합니다.

다음 예시에서는 compound 연산자를 사용하여 sample_mflix.movies 컬렉션에서 영화를 쿼리하며 다음 절을 사용합니다.

  • filter 제목에 friend라는 용어가 포함된 영화를 검색하는 절입니다.

  • must 2000년과 2015년 사이에 개봉된 영화를 찾는 절입니다.

  • mustNot 절은 Short, WesternBiography 장르에 속하지 않는 영화를 찾습니다.

이 쿼리는 $search 단계에서 scoreDetails 옵션을 지정하여 각 문서의 점수에 대한 자세한 분석을 결과에 조회합니다. 이 쿼리는 $limit 단계를 사용하여 결과를 3개 문서로 제한하고 $project 단계를 사용하여 다음을 수행합니다.

  • _id 필드를 제외합니다.

  • title, released, genres 필드만 포함하세요.

  • 결과에 score 필드를 추가하여 문서의 점수를 반환하고 scoreDetails 필드를 추가하여 문서의 점수에 대한 자세한 분석을 반환합니다.

1db.movies.aggregate([
2 {
3 "$search": {
4 "compound": {
5 "filter": [{
6 "text": {
7 "query": "friend",
8 "path": "title"
9 }
10 }],
11 "must": [{
12 "range": {
13 "path": "year",
14 "gte": 2000,
15 "lte": 2015
16 }
17 }],
18 "mustNot": [{
19 "text": {
20 "query": ["Short, Western", "Biography"],
21 "path": "genres"
22 }
23 }]
24 },
25 "scoreDetails": true
26 }
27 },
28 {
29 "$limit": 3
30 },
31 {
32 "$project": {
33 "_id": 0,
34 "title": 1,
35 "released": 1,
36 "genres": 1,
37 "score": { "$meta": "searchScore" },
38 "scoreDetails": { "$meta": "searchScoreDetails" }
39 }
40 }
41])
1[
2 {
3 genres: [ 'Comedy', 'Drama', 'Mystery' ],
4 title: 'With a Friend Like Harry...',
5 released: ISODate("2001-06-15T00:00:00.000Z"),
6 score: 1,
7 scoreDetails: {
8 value: 1,
9 description: 'sum of:',
10 details: [
11 {
12 value: 0,
13 description: 'match on required clause, product of:',
14 details: [
15 { value: 0, description: '# clause', details: [] },
16 {
17 value: 1,
18 description: '$type:string/title:friend',
19 details: []
20 }
21 ]
22 },
23 {
24 value: 1,
25 description: 'sum of:',
26 details: [
27 {
28 value: 1,
29 description: 'sum of:',
30 details: [
31 {
32 value: 1,
33 description: '$type:double/year:[4656510908468559872 TO 4656576879166226432]',
34 details: []
35 }
36 ]
37 }
38 ]
39 }
40 ]
41 }
42 },
43 {
44 genres: [ 'Drama' ],
45 title: 'My Friend Henry',
46 released: ISODate("2004-08-20T00:00:00.000Z"),
47 score: 1,
48 scoreDetails: {
49 value: 1,
50 description: 'sum of:',
51 details: [
52 {
53 value: 0,
54 description: 'match on required clause, product of:',
55 details: [
56 { value: 0, description: '# clause', details: [] },
57 {
58 value: 1,
59 description: '$type:string/title:friend',
60 details: []
61 }
62 ]
63 },
64 {
65 value: 1,
66 description: 'sum of:',
67 details: [
68 {
69 value: 1,
70 description: 'sum of:',
71 details: [
72 {
73 value: 1,
74 description: '$type:double/year:[4656510908468559872 TO 4656576879166226432]',
75 details: []
76 }
77 ]
78 }
79 ]
80 }
81 ]
82 }
83 },
84 {
85 genres: [ 'Comedy', 'Drama' ],
86 title: 'A Friend of Mine',
87 released: ISODate("2006-10-26T00:00:00.000Z"),
88 score: 1,
89 scoreDetails: {
90 value: 1,
91 description: 'sum of:',
92 details: [
93 {
94 value: 0,
95 description: 'match on required clause, product of:',
96 details: [
97 { value: 0, description: '# clause', details: [] },
98 {
99 value: 1,
100 description: '$type:string/title:friend',
101 details: []
102 }
103 ]
104 },
105 {
106 value: 1,
107 description: 'sum of:',
108 details: [
109 {
110 value: 1,
111 description: 'sum of:',
112 details: [
113 {
114 value: 1,
115 description: '$type:double/year:[4656510908468559872 TO 4656576879166226432]',
116 details: []
117 }
118 ]
119 }
120 ]
121 }
122 ]
123 }
124 }
125]

참고

15, 56, 97 줄의 결과에 있는 # clause는 문서 점수에 영향을 주지 않는 복합 쿼리 filter 절을 나타냅니다.

다음 예제에서는 embeddedDocument 연산자를 사용하여 sample_training.companies 컬렉션의 products.name 필드에서 용어 Basic과 해당 용어 앞으로 문자 여러 개가 이어지는 제품을 쿼리합니다. 쿼리는 embeddedDocument 연산자 내에서 반환된 점수가 일치하는 모든 내장된 문서의 합이어야 한다고 지정합니다. 또한 이 쿼리는 결과에 있는 각 문서의 점수에 대한 자세한 분석을 검색하기 위해 $search 단계에서 scoreDetails 옵션을 지정합니다. 이 쿼리는 $limit 단계를 사용하여 결과를 3개 문서로 제한하고 $project 단계를 사용하여 다음을 수행합니다.

  • _id 필드를 제외합니다.

  • products.name 필드만 포함합니다.

  • 결과에 score 필드를 추가하여 문서의 점수를 반환하고 scoreDetails 필드를 추가하여 문서의 점수에 대한 자세한 분석을 반환합니다.

1db.companies.aggregate({
2 "$search": {
3 "embeddedDocument": {
4 "path": "products",
5 "operator": {
6 "wildcard": {
7 "path": "products.name",
8 "query": "*Basic",
9 "allowAnalyzedField": true
10 }
11 },
12 "score": {
13 "embedded": {
14 "aggregate": "sum"
15 }
16 }
17 },
18 "scoreDetails": true
19 }
20},
21{
22 "$limit": 3
23},
24{
25 "$project": {
26 "_id": 0,
27 "name": 1,
28 "products.name": 1,
29 "score": { "$meta": "searchScore" },
30 "scoreDetails": { "$meta": "searchScoreDetails" }
31 }
32})
1[
2 {
3 name: 'Plaxo',
4 products: [
5 { name: 'Plaxo Basic' },
6 { name: 'Plaxo Pulse' },
7 { name: 'Plaxo Personal Assistant' }
8 ],
9 score: 1,
10 scoreDetails: {
11 value: 1,
12 description: 'Score based on 1 child docs in range from 27 to 29, best match:',
13 details: [
14 {
15 value: 1,
16 description: '$embedded:8/products/$type:string/products.name:*Basic',
17 details: []
18 }
19 ]
20 }
21 },
22 {
23 name: 'The Game Creators',
24 products: [
25 { name: 'Dark Basic Professional' },
26 { name: 'FPS Creator' },
27 { name: 'FPS Creator X10' }
28 ],
29 score: 1,
30 scoreDetails: {
31 value: 1,
32 description: 'Score based on 1 child docs in range from 7474 to 7476, best match:',
33 details: [
34 {
35 value: 1,
36 description: '$embedded:8/products/$type:string/products.name:*basic',
37 details: []
38 }
39 ]
40 }
41 },
42 {
43 name: 'Load Impact',
44 products: [
45 { name: 'Load Impact LIGHT' },
46 { name: 'Load Impact BASIC' },
47 { name: 'Load Impact PROFESSIONAL' },
48 { name: 'Load Impact ADVANCED' }
49 ],
50 score: 1,
51 scoreDetails: {
52 value: 1,
53 description: 'Score based on 1 child docs in range from 11545 to 11548, best match:',
54 details: [
55 {
56 value: 1,
57 description: '$embedded:8/products/$type:string/products.name:*basic',
58 details: []
59 }
60 ]
61 }
62 }
63]

참고

범위 내의 하위 문서를 기반으로 하는 점수의 경우 범위의 숫자는 내부적으로 Lucene에서 인덱싱한 상위 및 하위 문서의 ID를 나타냅니다. 하위 문서의 description(16, 36, 57행에서)은 경로의 내부 표현을 보여줍니다.

다음 $search scoreDetails 예제에서는 sample_mflix.movies collection에 대한 함수 표현식 예제 쿼리의 결과에 있는 문서에 대해 옵션을 사용하여 점수 분석을 검색하는 방법을 보여 줍니다.

1db.movies.aggregate([{
2 "$search": {
3 "text": {
4 "path": "title",
5 "query": "men",
6 "score": {
7 "function":{
8 "multiply":[
9 {
10 "path": {
11 "value": "imdb.rating",
12 "undefined": 2
13 }
14 },
15 {
16 "score": "relevance"
17 }
18 ]
19 }
20 }
21 },
22 "scoreDetails": true
23 }
24},
25{
26 $limit: 5
27},
28{
29 $project: {
30 "_id": 0,
31 "title": 1,
32 "score": { "$meta": "searchScore" },
33 "scoreDetails": {"$meta": "searchScoreDetails"}
34 }
35}])
[
{
title: 'Men...',
score: 23.431293487548828,
scoreDetails: {
value: 23.431293487548828,
description: 'FunctionScoreQuery($type:string/title:men, scored by (imdb.rating * scores)) [BM25Similarity], result of:',
details: [
{
value: 23.431293487548828,
description: '(imdb.rating * scores)',
details: []
}
]
}
},
{
title: '12 Angry Men',
score: 22.080968856811523,
scoreDetails: {
value: 22.080968856811523,
description: 'FunctionScoreQuery($type:string/title:men, scored by (imdb.rating * scores)) [BM25Similarity], result of:',
details: [
{
value: 22.080968856811523,
description: '(imdb.rating * scores)',
details: []
}
]
}
},
{
title: 'X-Men',
score: 21.34803581237793,
scoreDetails: {
value: 21.34803581237793,
description: 'FunctionScoreQuery($type:string/title:men, scored by (imdb.rating * scores)) [BM25Similarity], result of:',
details: [
{
value: 21.34803581237793,
description: '(imdb.rating * scores)',
details: []
}
]
}
},
{
title: 'X-Men',
score: 21.34803581237793,
scoreDetails: {
value: 21.34803581237793,
description: 'FunctionScoreQuery($type:string/title:men, scored by (imdb.rating * scores)) [BM25Similarity], result of:',
details: [
{
value: 21.34803581237793,
description: '(imdb.rating * scores)',
details: []
}
]
}
},
{
title: 'Matchstick Men',
score: 21.05954933166504,
scoreDetails: {
value: 21.05954933166504,
description: 'FunctionScoreQuery($type:string/title:men, scored by (imdb.rating * scores)) [BM25Similarity], result of:',
details: [
{
value: 21.05954933166504,
description: '(imdb.rating * scores)',
details: []
}
]
}
}
]
1db.movies.aggregate([
2 {
3 "$search": {
4 "text": {
5 "path": "title",
6 "query": "men",
7 "score": {
8 "function":{
9 "constant": 3
10 }
11 }
12 },
13 "scoreDetails": true
14 }
15 },
16 {
17 $limit: 5
18 },
19 {
20 $project: {
21 "_id": 0,
22 "title": 1,
23 "score": { "$meta": "searchScore" },
24 "scoreDetails": {"$meta": "searchScoreDetails"}
25 }
26 }
27])
[
{
title: 'Men Without Women',
score: 3,
scoreDetails: {
value: 3,
description: 'FunctionScoreQuery($type:string/title:men, scored by constant(3.0)) [BM25Similarity], result of:',
details: [ { value: 3, description: 'constant(3.0)', details: [] } ]
}
},
{
title: 'One Hundred Men and a Girl',
score: 3,
scoreDetails: {
value: 3,
description: 'FunctionScoreQuery($type:string/title:men, scored by constant(3.0)) [BM25Similarity], result of:',
details: [ { value: 3, description: 'constant(3.0)', details: [] } ]
}
},
{
title: 'Of Mice and Men',
score: 3,
scoreDetails: {
value: 3,
description: 'FunctionScoreQuery($type:string/title:men, scored by constant(3.0)) [BM25Similarity], result of:',
details: [ { value: 3, description: 'constant(3.0)', details: [] } ]
}
},
{
title: "All the King's Men",
score: 3,
scoreDetails: {
value: 3,
description: 'FunctionScoreQuery($type:string/title:men, scored by constant(3.0)) [BM25Similarity], result of:',
details: [ { value: 3, description: 'constant(3.0)', details: [] } ]
}
},
{
title: 'The Men',
score: 3,
scoreDetails: {
value: 3,
description: 'FunctionScoreQuery($type:string/title:men, scored by constant(3.0)) [BM25Similarity], result of:',
details: [ { value: 3, description: 'constant(3.0)', details: [] } ]
}
}
]
1db.movies.aggregate([
2 {
3 "$search": {
4 "text": {
5 "path": "title",
6 "query": "shop",
7 "score": {
8 "function":{
9 "gauss": {
10 "path": {
11 "value": "imdb.rating",
12 "undefined": 4.6
13 },
14 "origin": 9.5,
15 "scale": 5,
16 "offset": 0,
17 "decay": 0.5
18 }
19 }
20 }
21 },
22 "scoreDetails": true
23 }
24 },
25 {
26 "$limit": 10
27 },
28 {
29 "$project": {
30 "_id": 0,
31 "title": 1,
32 "score": { "$meta": "searchScore" },
33 "scoreDetails": {"$meta": "searchScoreDetails"}
34 }
35 }
36])
[
{
title: 'The Shop Around the Corner',
score: 0.9471074342727661,
scoreDetails: {
value: 0.9471074342727661,
description: 'FunctionScoreQuery($type:string/title:shop, scored by exp((max(0, |imdb.rating - 9.5| - 0.0)^2) / 2 * (5.0^2 / 2 * ln(0.5)))) [BM25Similarity], result of:',
details: [
{
value: 0.9471074342727661,
description: 'exp((max(0, |imdb.rating - 9.5| - 0.0)^2) / 2 * (5.0^2 / 2 * ln(0.5)))',
details: []
}
]
}
},
{
title: 'Exit Through the Gift Shop',
score: 0.9471074342727661,
scoreDetails: {
value: 0.9471074342727661,
description: 'FunctionScoreQuery($type:string/title:shop, scored by exp((max(0, |imdb.rating - 9.5| - 0.0)^2) / 2 * (5.0^2 / 2 * ln(0.5)))) [BM25Similarity], result of:',
details: [
{
value: 0.9471074342727661,
description: 'exp((max(0, |imdb.rating - 9.5| - 0.0)^2) / 2 * (5.0^2 / 2 * ln(0.5)))',
details: []
}
]
}
},
{
title: 'The Shop on Main Street',
score: 0.9395227432250977,
scoreDetails: {
value: 0.9395227432250977,
description: 'FunctionScoreQuery($type:string/title:shop, scored by exp((max(0, |imdb.rating - 9.5| - 0.0)^2) / 2 * (5.0^2 / 2 * ln(0.5)))) [BM25Similarity], result of:',
details: [
{
value: 0.9395227432250977,
description: 'exp((max(0, |imdb.rating - 9.5| - 0.0)^2) / 2 * (5.0^2 / 2 * ln(0.5)))',
details: []
}
]
}
},
{
title: 'Chop Shop',
score: 0.8849083781242371,
scoreDetails: {
value: 0.8849083781242371,
description: 'FunctionScoreQuery($type:string/title:shop, scored by exp((max(0, |imdb.rating - 9.5| - 0.0)^2) / 2 * (5.0^2 / 2 * ln(0.5)))) [BM25Similarity], result of:',
details: [
{
value: 0.8849083781242371,
description: 'exp((max(0, |imdb.rating - 9.5| - 0.0)^2) / 2 * (5.0^2 / 2 * ln(0.5)))',
details: []
}
]
}
},
{
title: 'Little Shop of Horrors',
score: 0.8290896415710449,
scoreDetails: {
value: 0.8290896415710449,
description: 'FunctionScoreQuery($type:string/title:shop, scored by exp((max(0, |imdb.rating - 9.5| - 0.0)^2) / 2 * (5.0^2 / 2 * ln(0.5)))) [BM25Similarity], result of:',
details: [
{
value: 0.8290896415710449,
description: 'exp((max(0, |imdb.rating - 9.5| - 0.0)^2) / 2 * (5.0^2 / 2 * ln(0.5)))',
details: []
}
]
}
},
{
title: 'The Suicide Shop',
score: 0.7257778644561768,
scoreDetails: {
value: 0.7257778644561768,
description: 'FunctionScoreQuery($type:string/title:shop, scored by exp((max(0, |imdb.rating - 9.5| - 0.0)^2) / 2 * (5.0^2 / 2 * ln(0.5)))) [BM25Similarity], result of:',
details: [
{
value: 0.7257778644561768,
description: 'exp((max(0, |imdb.rating - 9.5| - 0.0)^2) / 2 * (5.0^2 / 2 * ln(0.5)))',
details: []
}
]
}
},
{
title: 'A Woman, a Gun and a Noodle Shop',
score: 0.6559237241744995,
scoreDetails: {
value: 0.6559237241744995,
description: 'FunctionScoreQuery($type:string/title:shop, scored by exp((max(0, |imdb.rating - 9.5| - 0.0)^2) / 2 * (5.0^2 / 2 * ln(0.5)))) [BM25Similarity], result of:',
details: [
{
value: 0.6559237241744995,
description: 'exp((max(0, |imdb.rating - 9.5| - 0.0)^2) / 2 * (5.0^2 / 2 * ln(0.5)))',
details: []
}
]
}
},
{
title: 'Beauty Shop',
score: 0.6274620294570923,
scoreDetails: {
value: 0.6274620294570923,
description: 'FunctionScoreQuery($type:string/title:shop, scored by exp((max(0, |imdb.rating - 9.5| - 0.0)^2) / 2 * (5.0^2 / 2 * ln(0.5)))) [BM25Similarity], result of:',
details: [
{
value: 0.6274620294570923,
description: 'exp((max(0, |imdb.rating - 9.5| - 0.0)^2) / 2 * (5.0^2 / 2 * ln(0.5)))',
details: []
}
]
}
}
]
1db.movies.aggregate([{
2 "$search": {
3 "text": {
4 "path": "title",
5 "query": "men",
6 "score": {
7 "function":{
8 "path": {
9 "value": "imdb.rating",
10 "undefined": 4.6
11 }
12 }
13 }
14 },
15 "scoreDetails": true
16 }
17},
18{
19 $limit: 5
20},
21{
22 $project: {
23 "_id": 0,
24 "title": 1,
25 "score": { "$meta": "searchScore" },
26 "scoreDetails": {"$meta": "searchScoreDetails"}
27 }
28}])
[
{
title: '12 Angry Men',
score: 8.899999618530273,
scoreDetails: {
value: 8.899999618530273,
description: 'FunctionScoreQuery($type:string/title:men, scored by imdb.rating) [BM25Similarity], result of:',
details: [
{
value: 8.899999618530273,
description: 'imdb.rating',
details: []
}
]
}
},
{
title: 'The Men Who Built America',
score: 8.600000381469727,
scoreDetails: {
value: 8.600000381469727,
description: 'FunctionScoreQuery($type:string/title:men, scored by imdb.rating) [BM25Similarity], result of:',
details: [
{
value: 8.600000381469727,
description: 'imdb.rating',
details: []
}
]
}
},
{
title: 'No Country for Old Men',
score: 8.100000381469727,
scoreDetails: {
value: 8.100000381469727,
description: 'FunctionScoreQuery($type:string/title:men, scored by imdb.rating) [BM25Similarity], result of:',
details: [
{
value: 8.100000381469727,
description: 'imdb.rating',
details: []
}
]
}
},
{
title: 'X-Men: Days of Future Past',
score: 8.100000381469727,
scoreDetails: {
value: 8.100000381469727,
description: 'FunctionScoreQuery($type:string/title:men, scored by imdb.rating) [BM25Similarity], result of:',
details: [
{
value: 8.100000381469727,
description: 'imdb.rating',
details: []
}
]
}
},
{
title: 'The Best of Men',
score: 8.100000381469727,
scoreDetails: {
value: 8.100000381469727,
description: 'FunctionScoreQuery($type:string/title:men, scored by imdb.rating) [BM25Similarity], result of:',
details: [
{
value: 8.100000381469727,
description: 'imdb.rating',
details: []
}
]
}
}
]
1db.movies.aggregate([{
2 "$search": {
3 "text": {
4 "path": "title",
5 "query": "men",
6 "score": {
7 "function":{
8 "score": "relevance"
9 }
10 }
11 },
12 "scoreDetails": true
13 }
14},
15{
16 $limit: 5
17},
18{
19 $project: {
20 "_id": 0,
21 "title": 1,
22 "score": { "$meta": "searchScore" },
23 "scoreDetails": {"$meta": "searchScoreDetails"}
24 }
25}])
[
{
title: 'Men...',
score: 3.4457783699035645,
scoreDetails: {
value: 3.4457783699035645,
description: 'FunctionScoreQuery($type:string/title:men, scored by scores) [BM25Similarity], result of:',
details: [
{
value: 3.4457783699035645,
description: 'weight($type:string/title:men in 4705) [BM25Similarity], result of:',
details: [
{
value: 3.4457783699035645,
description: 'score(freq=1.0), computed as boost * idf * tf from:',
details: [
{
value: 5.5606818199157715,
description: 'idf, computed as log(1 + (N - n + 0.5) / (n + 0.5)) from:',
details: [
{
value: 90,
description: 'n, number of documents containing term',
details: []
},
{
value: 23529,
description: 'N, total number of documents with field',
details: []
}
]
},
{
value: 0.6196683645248413,
description: 'tf, computed as freq / (freq + k1 * (1 - b + b * dl / avgdl)) from:',
details: [
{
value: 1,
description: 'freq, occurrences of term within document',
details: []
},
{
value: 1.2000000476837158,
description: 'k1, term saturation parameter',
details: []
},
{
value: 0.75,
description: 'b, length normalization parameter',
details: []
},
{
value: 1,
description: 'dl, length of field',
details: []
},
{
value: 2.868375301361084,
description: 'avgdl, average length of field',
details: []
}
]
}
]
}
]
}
]
}
},
{
title: 'The Men',
score: 2.8848698139190674,
scoreDetails: {
value: 2.8848698139190674,
description: 'FunctionScoreQuery($type:string/title:men, scored by scores) [BM25Similarity], result of:',
details: [
{
value: 2.8848698139190674,
description: 'weight($type:string/title:men in 870) [BM25Similarity], result of:',
details: [
{
value: 2.8848698139190674,
description: 'score(freq=1.0), computed as boost * idf * tf from:',
details: [
{
value: 5.5606818199157715,
description: 'idf, computed as log(1 + (N - n + 0.5) / (n + 0.5)) from:',
details: [
{
value: 90,
description: 'n, number of documents containing term',
details: []
},
{
value: 23529,
description: 'N, total number of documents with field',
details: []
}
]
},
{
value: 0.5187978744506836,
description: 'tf, computed as freq / (freq + k1 * (1 - b + b * dl / avgdl)) from:',
details: [
{
value: 1,
description: 'freq, occurrences of term within document',
details: []
},
{
value: 1.2000000476837158,
description: 'k1, term saturation parameter',
details: []
},
{
value: 0.75,
description: 'b, length normalization parameter',
details: []
},
{
value: 2,
description: 'dl, length of field',
details: []
},
{
value: 2.868375301361084,
description: 'avgdl, average length of field',
details: []
}
]
}
]
}
]
}
]
}
},
{
title: 'Simple Men',
score: 2.8848698139190674,
scoreDetails: {
value: 2.8848698139190674,
description: 'FunctionScoreQuery($type:string/title:men, scored by scores) [BM25Similarity], result of:',
details: [
{
value: 2.8848698139190674,
description: 'weight($type:string/title:men in 6371) [BM25Similarity], result of:',
details: [
{
value: 2.8848698139190674,
description: 'score(freq=1.0), computed as boost * idf * tf from:',
details: [
{
value: 5.5606818199157715,
description: 'idf, computed as log(1 + (N - n + 0.5) / (n + 0.5)) from:',
details: [
{
value: 90,
description: 'n, number of documents containing term',
details: []
},
{
value: 23529,
description: 'N, total number of documents with field',
details: []
}
]
},
{
value: 0.5187978744506836,
description: 'tf, computed as freq / (freq + k1 * (1 - b + b * dl / avgdl)) from:',
details: [
{
value: 1,
description: 'freq, occurrences of term within document',
details: []
},
{
value: 1.2000000476837158,
description: 'k1, term saturation parameter',
details: []
},
{
value: 0.75,
description: 'b, length normalization parameter',
details: []
},
{
value: 2,
description: 'dl, length of field',
details: []
},
{
value: 2.868375301361084,
description: 'avgdl, average length of field',
details: []
}
]
}
]
}
]
}
]
}
},
{
title: 'X-Men',
score: 2.8848698139190674,
scoreDetails: {
value: 2.8848698139190674,
description: 'FunctionScoreQuery($type:string/title:men, scored by scores) [BM25Similarity], result of:',
details: [
{
value: 2.8848698139190674,
description: 'weight($type:string/title:men in 8368) [BM25Similarity], result of:',
details: [
{
value: 2.8848698139190674,
description: 'score(freq=1.0), computed as boost * idf * tf from:',
details: [
{
value: 5.5606818199157715,
description: 'idf, computed as log(1 + (N - n + 0.5) / (n + 0.5)) from:',
details: [
{
value: 90,
description: 'n, number of documents containing term',
details: []
},
{
value: 23529,
description: 'N, total number of documents with field',
details: []
}
]
},
{
value: 0.5187978744506836,
description: 'tf, computed as freq / (freq + k1 * (1 - b + b * dl / avgdl)) from:',
details: [
{
value: 1,
description: 'freq, occurrences of term within document',
details: []
},
{
value: 1.2000000476837158,
description: 'k1, term saturation parameter',
details: []
},
{
value: 0.75,
description: 'b, length normalization parameter',
details: []
},
{
value: 2,
description: 'dl, length of field',
details: []
},
{
value: 2.868375301361084,
description: 'avgdl, average length of field',
details: []
}
]
}
]
}
]
}
]
}
},
{
title: 'Mystery Men',
score: 2.8848698139190674,
scoreDetails: {
value: 2.8848698139190674,
description: 'FunctionScoreQuery($type:string/title:men, scored by scores) [BM25Similarity], result of:',
details: [
{
value: 2.8848698139190674,
description: 'weight($type:string/title:men in 8601) [BM25Similarity], result of:',
details: [
{
value: 2.8848698139190674,
description: 'score(freq=1.0), computed as boost * idf * tf from:',
details: [
{
value: 5.5606818199157715,
description: 'idf, computed as log(1 + (N - n + 0.5) / (n + 0.5)) from:',
details: [
{
value: 90,
description: 'n, number of documents containing term',
details: []
},
{
value: 23529,
description: 'N, total number of documents with field',
details: []
}
]
},
{
value: 0.5187978744506836,
description: 'tf, computed as freq / (freq + k1 * (1 - b + b * dl / avgdl)) from:',
details: [
{
value: 1,
description: 'freq, occurrences of term within document',
details: []
},
{
value: 1.2000000476837158,
description: 'k1, term saturation parameter',
details: []
},
{
value: 0.75,
description: 'b, length normalization parameter',
details: []
},
{
value: 2,
description: 'dl, length of field',
details: []
},
{
value: 2.868375301361084,
description: 'avgdl, average length of field',
details: []
}
]
}
]
}
]
}
]
}
}
]
1db.movies.aggregate([{
2 "$search": {
3 "text": {
4 "path": "title",
5 "query": "men",
6 "score": {
7 "function": {
8 "log": {
9 "path": {
10 "value": "imdb.rating",
11 "undefined": 10
12 }
13 }
14 }
15 }
16 },
17 "scoreDetails": true
18 }
19},
20{
21 $limit: 5
22},
23{
24 $project: {
25 "_id": 0,
26 "title": 1,
27 "score": { "$meta": "searchScore" },
28 "scoreDetails": {"$meta": "searchScoreDetails"}
29 }
30}])
[
{
title: '12 Angry Men',
score: 0.9493899941444397,
scoreDetails: {
value: 0.9493899941444397,
description: 'FunctionScoreQuery($type:string/title:men, scored by log(imdb.rating)) [BM25Similarity], result of:',
details: [
{
value: 0.9493899941444397,
description: 'log(imdb.rating)',
details: []
}
]
}
},
{
title: 'The Men Who Built America',
score: 0.9344984292984009,
scoreDetails: {
value: 0.9344984292984009,
description: 'FunctionScoreQuery($type:string/title:men, scored by log(imdb.rating)) [BM25Similarity], result of:',
details: [
{
value: 0.9344984292984009,
description: 'log(imdb.rating)',
details: []
}
]
}
},
{
title: 'No Country for Old Men',
score: 0.9084849953651428,
scoreDetails: {
value: 0.9084849953651428,
description: 'FunctionScoreQuery($type:string/title:men, scored by log(imdb.rating)) [BM25Similarity], result of:',
details: [
{
value: 0.9084849953651428,
description: 'log(imdb.rating)',
details: []
}
]
}
},
{
title: 'X-Men: Days of Future Past',
score: 0.9084849953651428,
scoreDetails: {
value: 0.9084849953651428,
description: 'FunctionScoreQuery($type:string/title:men, scored by log(imdb.rating)) [BM25Similarity], result of:',
details: [
{
value: 0.9084849953651428,
description: 'log(imdb.rating)',
details: []
}
]
}
},
{
title: 'The Best of Men',
score: 0.9084849953651428,
scoreDetails: {
value: 0.9084849953651428,
description: 'FunctionScoreQuery($type:string/title:men, scored by log(imdb.rating)) [BM25Similarity], result of:',
details: [
{
value: 0.9084849953651428,
description: 'log(imdb.rating)',
details: []
}
]
}
}
]

돌아가기

점수 수정