$search 단계에서 scoreDetails 불리언 옵션을 사용하면 쿼리 결과의 각 문서에 대한 점수를 자세히 분석할 수 있습니다.
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 검색 쿼리와 일치하는 이유에 대한 정보를 제공합니다. 자세한 학습 은 출력을 참조하세요.false- 결과에서 점수 분석의 세부 정보를 제외합니다. (기본값)
생략하면 scoreDetails 옵션의 기본값은 false 입니다.
$project 단계에서 scoreDetails 필드는 $meta 표현식을 취하며, 이는 다음 값을 요구합니다:
| 결과에 포함된 각 문서의 점수에 대한 자세한 분석을 반환합니다. |
출력
scoreDetails 옵션은 결과의 각 문서에 대해 scoreDetails 객체 내부의 details 배열에 다음 필드를 반환합니다.
필드 | 유형 | 설명 |
|---|---|---|
| float | |
| 문자열 | 문서에 점수를 매긴 방법과 점수 계산 시 고려된 요소에 대한 정보를 포함하는 채점 공식의 하위 집합입니다. 최상위 |
| 객체 배열 | 점수 공식의 하위 집합을 기반으로 문서에 있는 각 일치 항목의 점수 분석입니다. 이 값은 구조가 재귀적인 점수 세부 정보 객체의 배열입니다. |
점수에 기여하는 요소
다양한 쿼리 연산자는 결과 내 각 문서의 searchScore를 계산하기 위해 서로 다른 알고리즘을 사용합니다. 다음 섹션에서는 일반적인 쿼리 연산자가 점수 계산을 처리하는 방법을 설명합니다.
텍스트, 구문, 쿼리 문자열 및 자동 완성 연산자
기본적으로 text, phrase, queryString and autocomplete 연산자는 bm25 유사성 알고리즘을 사용하여 문서에 점수를 매깁니다.
여러 쿼리에서 일관된 결과가 필요할 때, 특히 다음 두 조건이 모두 충족되는 경우 stableTfl 또는 boolean 알고리즘을 사용하는 것이 좋습니다.
애플리케이션은
searchScore에 따라 결과를 정렬하고 결과를 페이지 매김합니다. 이는 중복 또는 문서 누락을 방지하기 위해 결정론적 점수에 의존합니다.배포서버에서 전용 MongoDB 검색 노드를 사용하거나 읽기 설정이
secondary또는nearest로 설정되어 있으면 초기 및 이후 쿼리가 서로 다른 MongoDB 검색하다 노드로 라우팅될 가능성이 높아집니다.
bm25 후속 쿼리 간에 점수가 일관적이지 않을 수 있습니다. 각 MongoDB 검색 노드는 MongoDB 검색 인덱스를 빌드하고 업데이트 및 삭제 작업을 독립적으로 수행하므로, 서로 다른 MongoDB 검색 노드 간에 문서 세트가 달라질 수 있습니다. bm25 계산은 문서 코퍼스에 의존하므로, 다른 MongoDB 검색 노드로 라우팅되는 후속 쿼리는 동일한 문서에 대해 서로 다른 bm25 점수를 계산할 수 있습니다.
다른 유사도 알고리즘을 사용하려면 MongoDB 검색 string 또는 autocomplete 유형으로 색인하는 필드에 대해 MongoDB 검색 인덱스 정의에서 similarity.type 속성을 지정합니다. 이러한 유형에 대해 MongoDB 검색 인덱스를 구성하는 방법은 String 필드를 인덱싱하는 방법 또는 자동 완성을 위한 필드를 인덱싱하는 방법을 참조하세요.
MongoDB 검색 인덱스 정의에서 similarity.type 속성을 지정할 때 다음 유사성 알고리즘 중에서 선택할 수 있습니다.
bm25
bm25 는 문서를 기준으로 순위를 매기는 인기 있는 순위 알고리즘입니다.
텀 빈도: 문서에 검색 텀 나타나는 빈도
역 문서 빈도: 검색 텀 모든 문서에서 얼마나 흔한지
필드 길이: 쿼리 와 일치하는 필드 의 길이
bm25 각 요인이 다음과 같이 정의되는 경우 점수를 boost * idf * tf로 계산합니다.
요인 | 설명 | |
|---|---|---|
| 쿼리 시점에 쿼리 연산자의 | |
| 쿼리 의 역 문서 빈도입니다. MongoDB Search는 다음 공식을 사용하여 빈도를 계산합니다. where:
| |
| 용어 빈도. MongoDB Search는 다음 공식을 사용하여 빈도를 계산합니다. where:
|
부울
boolean 은 각 쿼리 텀이 문서에 존재하는지 확인하고 발견된 텀의 수를 계산하는 점수 알고리즘입니다. 일치하는 모든 텀은 텀의 중요도나 빈도에 대한 조정 없이 동등하게 처리됩니다.
boolean의 경우, 점수는 문서에 존재하는 모든 쿼리 텀의 합으로 계산됩니다. 각 텀이 문서에 존재하는 경우 점수에 1의 값을 기여합니다.
stableTfl
stableTfl 은 텀의 길이를 사용하여 텀의 희귀성을 도출하는 사용자 지정 MongoDB 검색 순위 알고리즘입니다. 이는 긴 단어가 나타나는 빈도가 낮다(더 드물게)는 집프의 법칙에 근거한 것입니다.
stableTfl 각 요인이 다음과 같이 정의되는 경우 점수를 boost * tr * tf로 계산합니다.
요인 | 설명 | |
|---|---|---|
| 쿼리 시점에 쿼리 연산자의 | |
| 감소 함수. MongoDB 검색은 다음 수식을 사용하여 감소 함수를 계산합니다. where:
| |
| 텀 희귀도. MongoDB 검색는 다음 공식을 사용하여 텀의 희귀도를 계산합니다. where:
| |
| 확률 함수는 Zipf의 법칙에 기반합니다. MongoDB 검색는 다음 공식을 사용하여 문서에 쿼리 텀이 나타날 확률을 계산합니다. where:
|
near 연산자
near 연산자는 거리 감소 함수를 사용하여 문서에 점수를 매깁니다. origin 값으로 설정한 숫자, 날짜 또는 지리적 위치에 대해 MongoDB 검색 결과의 근접성을 측정합니다.
거리 감소 함수는 점수를 pivot / (pivot +
distance)로 계산하며, 각 요소는 다음과 같이 정의됩니다.
요인 | 설명 | |
|---|---|---|
|
| |
|
where:
|
예시
다음 예에서는 다음에 대한 결과에서 점수의 세부 정보를 검색하는 방법을 보여 줍니다.
쿼리는 text, near, 복합 및 embeddedDocument 연산자를 사용하여 실행됩니다.
function옵션 표현식을 사용하여 점수가 수정된 쿼리입니다.
팁
객체 배열에서 재귀적으로 점수의 세부 정보를 보려면 다음을 실행하여 mongosh 에서 설정을 구성합니다.
config.set('inspectDepth', Infinity)
연산자 예제
다음 예제에서는 텍스트 , near , 복합 및 embeddedDocument 연산자 쿼리에 대한 결과의 문서에 대해 옵션을 사용하여 점수 분석을 검색하는 방법을 보여 줍니다.$search scoreDetails
사용자 지정 점수 예시
다음 $search scoreDetails 예제에서는 sample_mflix.movies collection에 대한 함수 표현식 예제 쿼리의 결과에 있는 문서에 대해 옵션을 사용하여 점수 분석을 검색하는 방법을 보여 줍니다.
1 db.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: [] } ] } } ]
1 db.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: [] } ] } } ]
1 db.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: [] } ] } } ]
1 db.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: [] } ] } } ]
1 db.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: [] } ] } ] } ] } ] } } ]
1 db.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: [] } ] } } ]