File tree Expand file tree Collapse file tree 5 files changed +26
-10
lines changed
packages/compass-aggregations/src
pipeline-builder-workspace/pipeline-as-text-workspace Expand file tree Collapse file tree 5 files changed +26
-10
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import OutputStagePreview from '../stage-preview/output-stage-preview';
1616import { AtlasStagePreview } from '../stage-preview/atlas-stage-preview' ;
1717import {
1818 isAtlasOnlyStage ,
19+ isSearchStage ,
1920 isMissingAtlasStageSupport ,
2021 isOutputStage ,
2122} from '../../utils/stage' ;
@@ -24,7 +25,7 @@ import {
2425 expandPreviewDocsForStage ,
2526} from '../../modules/pipeline-builder/stage-editor' ;
2627import type { StoreStage } from '../../modules/pipeline-builder/stage-editor' ;
27- import AtlasNoResults from '../atlas -no-results' ;
28+ import SearchNoResults from '../search -no-results' ;
2829
2930const containerStyles = css ( {
3031 display : 'flex' ,
@@ -150,8 +151,8 @@ export const FocusModePreview = ({
150151 className = { documentListStyles }
151152 />
152153 ) ;
153- } else if ( isAtlasOnlyStage ( stageOperator ) ) {
154- content = < AtlasNoResults /> ;
154+ } else if ( isSearchStage ( stageOperator ) ) {
155+ content = < SearchNoResults /> ;
155156 } else {
156157 content = (
157158 < div className = { centerStyles } >
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ import {
2525 expandPreviewDocs ,
2626 collapsePreviewDocs ,
2727} from '../../../modules/pipeline-builder/text-editor-pipeline' ;
28- import AtlasNoResults from '../../atlas -no-results' ;
28+ import SearchNoResults from '../../search -no-results' ;
2929
3030const containerStyles = css ( {
3131 display : 'flex' ,
@@ -128,7 +128,7 @@ const PreviewResults = ({
128128
129129 if ( previewDocs . length === 0 ) {
130130 if ( atlasOperator ) {
131- return < AtlasNoResults /> ;
131+ return < SearchNoResults /> ;
132132 }
133133 return (
134134 < div className = { centerStyles } >
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ const missingAtlasIndexDarkStyles = css({
2727 color : palette . green . base ,
2828} ) ;
2929
30- export default function AtlasNoResults ( ) {
30+ export default function SearchNoResults ( ) {
3131 const darkMode = useDarkMode ( ) ;
3232
3333 return (
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ import { Document } from '@mongodb-js/compass-crud';
1414
1515import type { RootState } from '../../modules' ;
1616import {
17- isAtlasOnlyStage ,
17+ isSearchStage ,
1818 isMissingAtlasStageSupport ,
1919 isOutputStage ,
2020} from '../../utils/stage' ;
@@ -25,7 +25,7 @@ import OutputStagePreivew from './output-stage-preview';
2525import StagePreviewHeader from './stage-preview-header' ;
2626import type { StoreStage } from '../../modules/pipeline-builder/stage-editor' ;
2727
28- import AtlasNoResults from '../atlas -no-results' ;
28+ import SearchNoResults from '../search -no-results' ;
2929
3030const centeredContent = css ( {
3131 display : 'flex' ,
@@ -145,8 +145,8 @@ function StagePreviewBody({
145145 ) ;
146146 }
147147
148- if ( isAtlasOnlyStage ( stageOperator ?? '' ) && documents ?. length === 0 ) {
149- return < AtlasNoResults /> ;
148+ if ( isSearchStage ( stageOperator ) && documents ?. length === 0 ) {
149+ return < SearchNoResults /> ;
150150 }
151151
152152 if ( documents && documents . length > 0 ) {
Original file line number Diff line number Diff line change @@ -203,6 +203,21 @@ export function isAtlasOnlyStage(
203203 return ! ! stageOperator && ATLAS_ONLY_OPERATOR_NAMES . has ( stageOperator ) ;
204204}
205205
206+ /*
207+ Atlas Search does not return an error if there is no search index - it just
208+ returns no results. So if the connection has access to Atlas Search and the
209+ aggregation used a search-related stage and got no results we want to display a
210+ different error.
211+ */
212+ export function isSearchStage (
213+ stageOperator : string | null | undefined
214+ ) : stageOperator is '$search' | '$searchMeta' | '$vectorSearch' {
215+ if ( ! stageOperator ) {
216+ return false ;
217+ }
218+ return [ '$search' , '$searchMeta' , '$vectorSearch' ] . includes ( stageOperator ) ;
219+ }
220+
206221const STAGE_OPERATORS_MAP = new Map (
207222 STAGE_OPERATORS . map ( ( stage ) => [ stage . value , stage ] )
208223) ;
You can’t perform that action at this time.
0 commit comments