Skip to content

Commit fdcdf7d

Browse files
committed
docs: add NOT operator examples to km examples
Show how to exclude terms with NOT and standalone NOT queries.
1 parent 6933d5a commit fdcdf7d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/Main/CLI/Commands/ExamplesCommand.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,13 @@ private void ShowSearchExamples()
139139
AnsiConsole.MarkupLine("[dim]Find documents with either python or javascript[/]");
140140
AnsiConsole.WriteLine();
141141

142+
AnsiConsole.MarkupLine("[bold]Exclude terms with NOT[/]");
143+
AnsiConsole.MarkupLine("[cyan]km search \"docker AND NOT kubernetes\"[/]");
144+
AnsiConsole.MarkupLine("[dim]Find docker docs that don't mention kubernetes[/]");
145+
AnsiConsole.MarkupLine("[cyan]km search \"NOT deprecated\"[/]");
146+
AnsiConsole.MarkupLine("[dim]Find all docs that don't contain \"deprecated\"[/]");
147+
AnsiConsole.WriteLine();
148+
142149
AnsiConsole.MarkupLine("[bold]Search for literal reserved words[/]");
143150
AnsiConsole.MarkupLine("[cyan]km search '\"NOT\"'[/]");
144151
AnsiConsole.MarkupLine("[dim]Use quotes to search for literal AND, OR, NOT as words[/]");
@@ -162,6 +169,13 @@ private void ShowSearchExamples()
162169
AnsiConsole.MarkupLine("[dim]Full-text search across all fields[/]");
163170
AnsiConsole.WriteLine();
164171

172+
AnsiConsole.MarkupLine("[bold]JSON format - exclude with $not and $nor[/]");
173+
AnsiConsole.MarkupLine($"[cyan]{Markup.Escape("km search '{\"content\": {\"$not\": \"deprecated\"}}'")}[/]");
174+
AnsiConsole.MarkupLine("[dim]Find docs where content doesn't contain \"deprecated\"[/]");
175+
AnsiConsole.MarkupLine($"[cyan]{Markup.Escape("km search '{\"$nor\": [{\"content\": \"alpha\"}, {\"content\": \"beta\"}]}'")}[/]");
176+
AnsiConsole.MarkupLine("[dim]Exclude docs containing \"alpha\" or \"beta\"[/]");
177+
AnsiConsole.WriteLine();
178+
165179
AnsiConsole.MarkupLine("[bold]JSON format - escaping special characters[/]");
166180
AnsiConsole.MarkupLine($"[cyan]{Markup.Escape("km search '{\"content\": \"quotes: \\\"hello\\\"\"}'")}[/]");
167181
AnsiConsole.MarkupLine("[dim]Escape quotes in JSON with backslash[/]");

0 commit comments

Comments
 (0)