@@ -606,4 +606,143 @@ public async Task RegressionTest_FieldSpecificEqualOperator_ExtractsFtsQuery()
606606 }
607607
608608 #endregion
609+
610+ #region Known Issue 2: Quoted Phrases With Reserved Words
611+
612+ [ Fact ]
613+ public async Task KnownIssue2_QuotedPhraseWithAND_FindsExactPhrase ( )
614+ {
615+ // Known Issue 2: Quoted phrases don't escape operators
616+ // This test verifies that searching for "Alice AND Bob" (as a phrase)
617+ // finds documents containing that exact phrase, not documents with "Alice" AND "Bob" separately
618+
619+ // Arrange
620+ await this . InsertAsync ( "doc1" , "Meeting with Alice AND Bob" ) . ConfigureAwait ( false ) ;
621+ await this . InsertAsync ( "doc2" , "Alice went to lunch and Bob stayed" ) . ConfigureAwait ( false ) ;
622+ await this . InsertAsync ( "doc3" , "Just Alice here" ) . ConfigureAwait ( false ) ;
623+ await this . InsertAsync ( "doc4" , "Just Bob here" ) . ConfigureAwait ( false ) ;
624+
625+ // Act: Search for the exact phrase "Alice AND Bob" using quotes
626+ var response = await this . SearchAsync ( "\" Alice AND Bob\" " ) . ConfigureAwait ( false ) ;
627+
628+ // Assert: Should find only doc1 which contains the exact phrase
629+ Assert . Equal ( 1 , response . TotalResults ) ;
630+ Assert . Single ( response . Results ) ;
631+ Assert . Equal ( this . _insertedIds [ "doc1" ] , response . Results [ 0 ] . Id ) ;
632+ }
633+
634+ [ Fact ]
635+ public async Task KnownIssue2_QuotedPhraseWithOR_FindsExactPhrase ( )
636+ {
637+ // Known Issue 2: Quoted phrases don't escape operators
638+ // This test verifies that "this OR that" searches for the literal phrase
639+
640+ // Arrange
641+ await this . InsertAsync ( "doc1" , "choose this OR that option" ) . ConfigureAwait ( false ) ;
642+ await this . InsertAsync ( "doc2" , "this is one option or that is another" ) . ConfigureAwait ( false ) ;
643+ await this . InsertAsync ( "doc3" , "just this" ) . ConfigureAwait ( false ) ;
644+ await this . InsertAsync ( "doc4" , "just that" ) . ConfigureAwait ( false ) ;
645+
646+ // Act: Search for the exact phrase "this OR that"
647+ var response = await this . SearchAsync ( "\" this OR that\" " ) . ConfigureAwait ( false ) ;
648+
649+ // Assert: Should find only doc1 with the exact phrase
650+ Assert . Equal ( 1 , response . TotalResults ) ;
651+ Assert . Single ( response . Results ) ;
652+ Assert . Equal ( this . _insertedIds [ "doc1" ] , response . Results [ 0 ] . Id ) ;
653+ }
654+
655+ [ Fact ]
656+ public async Task KnownIssue2_QuotedPhraseWithNOT_FindsExactPhrase ( )
657+ {
658+ // Known Issue 2: Quoted phrases don't escape operators
659+ // This test verifies that "this is NOT important" searches for the literal phrase
660+
661+ // Arrange
662+ await this . InsertAsync ( "doc1" , "this is NOT important notice" ) . ConfigureAwait ( false ) ;
663+ await this . InsertAsync ( "doc2" , "this is definitely important" ) . ConfigureAwait ( false ) ;
664+ await this . InsertAsync ( "doc3" , "NOT a problem" ) . ConfigureAwait ( false ) ;
665+
666+ // Act: Search for the exact phrase "this is NOT important"
667+ var response = await this . SearchAsync ( "\" this is NOT important\" " ) . ConfigureAwait ( false ) ;
668+
669+ // Assert: Should find only doc1 with the exact phrase
670+ Assert . Equal ( 1 , response . TotalResults ) ;
671+ Assert . Single ( response . Results ) ;
672+ Assert . Equal ( this . _insertedIds [ "doc1" ] , response . Results [ 0 ] . Id ) ;
673+ }
674+
675+ [ Fact ]
676+ public async Task KnownIssue2_QuotedReservedWordAND_FindsDocumentsContainingAND ( )
677+ {
678+ // Known Issue 2: Searching for just the word "AND" should work when quoted
679+
680+ // Arrange
681+ await this . InsertAsync ( "doc1" , "The word AND appears here" ) . ConfigureAwait ( false ) ;
682+ await this . InsertAsync ( "doc2" , "No reserved words" ) . ConfigureAwait ( false ) ;
683+
684+ // Act: Search for the literal word "AND"
685+ var response = await this . SearchAsync ( "\" AND\" " ) . ConfigureAwait ( false ) ;
686+
687+ // Assert: Should find doc1 containing "AND"
688+ Assert . Equal ( 1 , response . TotalResults ) ;
689+ Assert . Equal ( this . _insertedIds [ "doc1" ] , response . Results [ 0 ] . Id ) ;
690+ }
691+
692+ [ Fact ]
693+ public async Task KnownIssue2_QuotedReservedWordOR_FindsDocumentsContainingOR ( )
694+ {
695+ // Known Issue 2: Searching for just the word "OR" should work when quoted
696+
697+ // Arrange
698+ await this . InsertAsync ( "doc1" , "The word OR appears here" ) . ConfigureAwait ( false ) ;
699+ await this . InsertAsync ( "doc2" , "No reserved words" ) . ConfigureAwait ( false ) ;
700+
701+ // Act: Search for the literal word "OR"
702+ var response = await this . SearchAsync ( "\" OR\" " ) . ConfigureAwait ( false ) ;
703+
704+ // Assert: Should find doc1 containing "OR"
705+ Assert . Equal ( 1 , response . TotalResults ) ;
706+ Assert . Equal ( this . _insertedIds [ "doc1" ] , response . Results [ 0 ] . Id ) ;
707+ }
708+
709+ [ Fact ]
710+ public async Task KnownIssue2_QuotedReservedWordNOT_FindsDocumentsContainingNOT ( )
711+ {
712+ // Known Issue 2: Searching for just the word "NOT" should work when quoted
713+
714+ // Arrange
715+ await this . InsertAsync ( "doc1" , "The word NOT appears here" ) . ConfigureAwait ( false ) ;
716+ await this . InsertAsync ( "doc2" , "No reserved words" ) . ConfigureAwait ( false ) ;
717+
718+ // Act: Search for the literal word "NOT"
719+ var response = await this . SearchAsync ( "\" NOT\" " ) . ConfigureAwait ( false ) ;
720+
721+ // Assert: Should find doc1 containing "NOT"
722+ Assert . Equal ( 1 , response . TotalResults ) ;
723+ Assert . Equal ( this . _insertedIds [ "doc1" ] , response . Results [ 0 ] . Id ) ;
724+ }
725+
726+ [ Fact ]
727+ public async Task KnownIssue2_MixedQuotedPhraseAndOperator_WorksCorrectly ( )
728+ {
729+ // Known Issue 2: Mixing quoted phrases with actual operators should work
730+ // Search: "Alice AND Bob" AND kubernetes
731+ // This should find documents containing both the exact phrase "Alice AND Bob" AND the word "kubernetes"
732+
733+ // Arrange
734+ await this . InsertAsync ( "doc1" , "Meeting notes for Alice AND Bob about kubernetes" ) . ConfigureAwait ( false ) ;
735+ await this . InsertAsync ( "doc2" , "Meeting notes for Alice AND Bob about docker" ) . ConfigureAwait ( false ) ;
736+ await this . InsertAsync ( "doc3" , "Meeting notes for Alice about kubernetes" ) . ConfigureAwait ( false ) ;
737+
738+ // Act: Search for exact phrase AND another term
739+ var response = await this . SearchAsync ( "\" Alice AND Bob\" AND kubernetes" ) . ConfigureAwait ( false ) ;
740+
741+ // Assert: Should find only doc1
742+ Assert . Equal ( 1 , response . TotalResults ) ;
743+ Assert . Single ( response . Results ) ;
744+ Assert . Equal ( this . _insertedIds [ "doc1" ] , response . Results [ 0 ] . Id ) ;
745+ }
746+
747+ #endregion
609748}
0 commit comments