Atlas Search
Atlas Search operator, compound/filter, score, highlight, sequence token, paging/count와 Driver-native 확장 경로를 1.0.0 기준으로 구성합니다.
기본 Atlas Search
$search와 $searchMeta는 aggregation pipeline의 첫 stage여야 하므로 일반 fields(...).end() 흐름과 분리되어 있습니다. index를 생략한 .search()도 사용할 수 있습니다.
Search operator
• root builder: text, phrase, autocomplete, equals, exists, in, range, compound
• reusable clause: SearchOperators.text/phrase/autocomplete/equals/in/exists/range
• Driver-native root operator: operator(SearchOperator)
• named Driver wrapper: SearchOperators.driver(name, operator)
compound는 must, mustNot, should, filter, minimumShouldMatch, score를 지원하며 일반 AtlasSearchOperator를 직접 전달할 수도 있습니다.
Text / Phrase / Autocomplete
• text: path(s), query(ies), fuzzy, matchCriteria, synonyms, score
• phrase: path(s), query(ies), slop, synonyms, score
• autocomplete: single path, query(ies), tokenOrder, fuzzy, score
• fuzzy(...)와 synonyms(...)는 동시에 사용하지 않습니다.
Search clause와 post-search fields의 차이
search().fields(...)는 $search 내부 filter가 아니라 $search 뒤의 일반 $match입니다. Search index 단계에서 후보를 제한하려면 compound.filter(...)를 사용합니다.
Score와 정렬
scoreDesc()/scoreAsc()와 일반 sort는 호출한 순서대로 priority가 정해집니다. 안정적인 pagination을 위해 score와 함께 stable unique field 정렬을 두는 것이 좋습니다.
Highlight / score details / sequence token
기본 alias는 highlights, scoreDetails, searchSequenceToken입니다. addFieldsScoreDetails()는 Search option의 score details도 활성화합니다.
Paging / sequence token / count
count().execute()
post-search fields(...)와 score threshold까지 반영한 최종 pipeline count입니다.
count().executeSearchMeta()
$searchMeta metadata count입니다. SearchCountType.TOTAL/LOWER_BOUND를 지원하며 post-search $match는 실행하지 않습니다.
existsQuery().execute()
Search pipeline 결과가 한 건 이상 존재하는지 확인합니다.
Driver-native 확장
stage(Bson)은 $search 직후에 들어가며 executeSearchMeta()의 $searchMeta metadata-count pipeline에는 적용되지 않습니다. 새 Driver 기능이 DSL convenience API보다 먼저 추가되면 operator, driverOptions, stage, SortSpec.driver, customizeAggregation을 우선 사용합니다.