Docs Menu
Docs Home
/ /

점수 상세 정보 반환

단계에서 scoreDetails 부울 옵션을 사용하면 $search 쿼리 결과의 각 문서 에 대한 점수를 자세히 분석할 수 있습니다.

단계에서 를 scoreDetails: true $search 설정하다 하면 MongoDB Search는 일치하는 각 문서 에 대한 자세한 점수 정보를 반환합니다. 이 정보는 문서 쿼리 와 일치하고 검색 결과에서 관련성 점수를 받은 이유를 설명합니다.

기본값 으로 점수는 bm25 공식을 기반으로 합니다.

  • 용어 빈도: 문서 에 검색 텀 나타나는 빈도

  • 역 문서 빈도: 검색 텀 모든 문서에서 얼마나 흔한지

  • 필드 길이: 쿼리 와 일치하는 필드 의 길이

scoreDetails 옵션은 이러한 요소를 세분화하여 문서 쿼리 와 일치하고 점수를 받은 이유 분석 데 도움이 됩니다.

메타데이터 를 보려면 단계에서 $meta 표현식 $project 사용해야 합니다.

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

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

  • true - 결과에 문서의 점수 세부 정보를 포함합니다. 로 true 설정하다 하면 MongoDB Search는 결과의 각 문서 에 대한 자세한 점수 분석을 반환합니다. 이는 특정 문서가 MongoDB Search 쿼리 와 일치하는 이유에 대한 정보를 제공합니다.자세한 학습 은 출력을 참조하세요.

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

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

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

searchScoreDetails

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

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

필드
유형
설명

value

float

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

점수 공식은 쿼리 에 사용된 연산자 에 따라 달라집니다. 예시 들어, MongoDB Search는 거리 감쇠 함수를 사용하여 근거리 연산자 의 점수를 계산합니다.

description

문자열

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

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

details

객체 배열

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

쿼리 연산자마다 다른 알고리즘을 사용하여 결과의 각 문서 에 대한 searchScore 를 계산합니다. 다음 섹션에서는 일반적인 쿼리 연산자에서 점수를 처리하다 방법을 설명합니다.

기본값 으로 텍스트, 구문, queryString 및 자동 완성 연산자는 유사성 bm25 알고리즘 사용하여 문서에 점수를 매깁니다.

여러 쿼리에서 일관적인 결과가 필요한 경우, 특히 다음 두 가지 모두에 해당하는 경우 stableTfl 또는 boolean 알고리즘을 사용하는 것이 좋습니다.

  • 애플리케이션 를 기준으로 결과를 searchScore 정렬하고 결과에 페이지를 매기는데, 결정론적 점수에 의존하여 중복되거나 문서를 건너뛰는 것을 방지합니다.

  • 배포서버 전용 MongoDB Search 노드를 사용하거나 읽기 설정 (read preference) 또는 로 설정하다 secondary nearest되어 있으면 초기 및 후속 쿼리가 다른 MongoDB Search 노드로 라우팅될 가능성이 높아집니다.

bm25 후속 쿼리 간에는 점수가 일관적인 되지 않을 수 있습니다. 각 MongoDB Search 노드 MongoDB Search 인덱스를 빌드하고 업데이트 및 삭제 작업을 독립적으로 수행하므로 문서 코퍼스는 MongoDB Search 노드마다 다를 수 있습니다. bm25 계산은 문서 코퍼스에 따라 달라지므로, 다른 MongoDB Search 노드로 라우팅되는 후속 쿼리는 동일한 문서에 대해 서로 다른 bm25 점수를 계산할 수 있습니다.

다른 유사성 알고리즘 similarity.type 사용하려면 MongoDB Search 또는 유형으로 인덱스 필드에 대해 MongoDB Search 인덱스 정의에서 string 속성 autocomplete 지정합니다. 이러한 유형에 대해 MongoDB Search 인덱스 구성하는 방법을 학습 문자열 필드를 인덱싱하는 방법 또는 자동 완성을 위해 필드를 인덱싱하는 방법을 참조하세요.

MongoDB Search 인덱스 정의에서 similarity.type 속성 지정할 때 다음 유사성 알고리즘 중에서 선택할 수 있습니다.

bm25 다음을 기준으로 문서 순위를 매기는 인기 있는 순위 알고리즘 입니다.

  • 용어 빈도: 문서 에 검색 텀 나타나는 빈도

  • 역 문서 빈도: 검색 텀 모든 문서에서 얼마나 흔한지

  • 필드 길이: 쿼리 와 일치하는 필드 의 길이

bm25 점수를 boost * idf * tf로 계산하며, 각 요인은 다음과 같이 정의됩니다.

요인
설명

boost

쿼리 연산자의 옵션을 사용하여 쿼리 시 score.boost 지정된 인수입니다. 을 boost 양수 또는 문서의 숫자 필드 값으로 설정하다 수 있습니다. 자세한 학습 boost를 참조하세요.

idf

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

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

where:

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

  • n 는 쿼리 텀 포함하는 문서 수입니다.

tf

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

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

where:

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

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

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

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

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

boolean 문서 에 각 쿼리 텀 가 있는지 확인하고 발견된 용어의 수를 계산하는 채점 알고리즘 입니다. 일치하는 모든 용어는 텀 중요도나 빈도에 대한 조정 없이 동등하게 취급됩니다.

boolean 의 경우 점수는 문서 에 있는 모든 쿼리 용어의 합계로 계산되며, 각 텀 는 문서 에 있는 경우 점수에 1 값을 기여합니다.

stableTfl 텀의 길이를 사용하여 텀 희소성을 도출하는 사용자 지정 MongoDB Search 순위 알고리즘 입니다. 이는 긴 단어가 더 자주 표시되지 않는다는 Zipf의 법칙을 기반으로 합니다(더 드물게 표시됨).

stableTfl 점수를 boost * tr * tf로 계산하며, 각 요인은 다음과 같이 정의됩니다.

요인
설명

boost

쿼리 연산자의 옵션을 사용하여 쿼리 시 score.boost 지정된 인수입니다. 을 boost 양수 또는 문서의 숫자 필드 값으로 설정하다 수 있습니다. 자세한 학습 boost를 참조하세요.

tf

감쇠 기능. MongoDB Search는 다음 공식을 사용하여 감쇠 함수를 계산합니다.

tf = freq / (freq + k1)

where:

  • freq 는 문서 에서 쿼리 텀 의 빈도입니다.

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

tr

용어 희소성. MongoDB Search는 다음 공식을 사용하여 텀 희소성을 계산합니다.

tr = log(1 + (1 - p + 0.05)/(p + 0.05))

where:

  • p 는 텀 길이에 따라 쿼리 텀 문서 에 나타날 확률입니다. 이는 긴 단어가 표시되는 빈도가 낮다는 Zipf의 법칙을 기반으로 합니다. 텀 희소성을 결정하기 위해 MongoDB 텀 길이에 따라 감쇠 함수를 사용합니다.

p

Zipf의 법칙에 기반한 확률 함수입니다. MongoDB Search는 다음 공식을 사용하여 쿼리 텀 문서 에 나타날 확률을 계산합니다.

p = 1 - (1 - m * 2 ^ (-c * tl)) ^ dl

where:

  • m 내부적으로 지정된 텀 확률에 대한 곱셈 상수입니다.

  • c 내부적으로 지정된 감쇠 상수입니다. 텀 길이가 증가함에 따라 p 가 얼마나 빨리 감소하는지 제어합니다.

  • tl 유니코드 코드포인트로 측정한 쿼리 텀 의 길이입니다.

  • dl 토큰으로 측정된 문서 d의 길이입니다.

근거리 연산자 거리 감쇠 함수를 사용하여 문서에 점수를 매깁니다. 값으로 설정하다 숫자, 날짜 또는 지리적 origin 에 대한 MongoDB Search 결과의 근접성을 측정합니다.

거리 감쇠 함수는 점수를 pivot / (pivot + distance)로 계산하며, 여기서 각 요인은 다음과 같이 정의됩니다.

요인
설명

pivot

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

distance

fieldValue 와(과) origin 사이의 절대 거리입니다. MongoDB Search는 다음 공식을 사용하여 이 값을 계산합니다.

abs(fieldValue - origin)

where:

  • fieldValue 문서 에서 쿼리하는 필드 의 값입니다.

  • origin 근처에서 검색 할 숫자, 날짜 또는 지리적 점 입니다.

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

객체 배열에서 재귀적으로 점수의 세부 정보를 보려면 다음을 실행하여 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]

MongoDB Search는 점수를 계산할 때 다음 BM25Similarity 요인을 고려합니다.

요인
설명

boost

쿼리 연산자의 옵션을 사용하여 쿼리 시 score.boost 지정된 인수입니다. 을 boost 양수 또는 문서의 숫자 필드 값으로 설정하다 수 있습니다. 자세한 학습 boost를 참조하세요.

idf

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

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

where:

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

  • n 는 쿼리 텀 포함하는 문서 수입니다.

tf

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

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

where:

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

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

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

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

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

다음 예시에서는 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]

거리 점수의 경우 MongoDB Search는 점수를 계산할 때 다음 요소를 고려합니다.

요인
설명

pivot

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

distance

fieldValue 와(과) origin 사이의 절대 거리입니다. MongoDB Search는 다음 공식을 사용하여 이 값을 계산합니다.

abs(fieldValue - origin)

where:

  • fieldValue 문서 에서 쿼리하는 필드 의 값입니다.

  • origin 근처에서 검색 할 숫자, 날짜 또는 지리적 점 입니다.

다음 예시에서는 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: []
}
]
}
}
]

돌아가기

점수 산정 옵션

이 페이지의 내용