Cara menggunakan mongodb atlas fuzzy search
The Character Description
Matches any single character.
Matches 0 or more characters.
Escape character.
0 field is not analyzed. Term-level operators work well with the , because the 0 field is treated as a single term, with special characters included. For an example of querying against an analyzed 0 field vs. a non-analyzed 0 field, see theSyntax
Options
Field Type Description Necessity Default
string or array of strings String or strings to search for. yes
string or array of strings Indexed field or fields to search. You can also specify a to search. See for more information. yes
boolean Must be set to no
object Modify the assigned to matching search term results. Options are: 3: replace the result score with the given number.no Behavior
0 field is not analyzed. It is possible to use the wildcard operator to perform searches on a field analyzed during indexing by setting the 8 option to 9, but results will reflect that the query text is not analyzed.ExampleSuppose that a field 9 is indexed with the . Atlas Search analyzes and indexes the field as 0, 1 and 2. Searching for 3 on this field finds nothing, because the wildcard operator treats 3 as a single search term with a wildcard at the end. In other words, Atlas Search searches the field for any term that begins with 5 but finds nothing, because no term exists.ExampleSearching for 6 on a field indexed with the 7 analyzer finds all documents in which the field contains the string 8 in any context. Searching for 6 on a field indexed with the finds nothing, because there is a space between wildcard 0 and wildcard 1, and the index contains no spaces.Escape Character BehaviorWhen using the escape character in or with a driver, you must use a double backslash before the character to be escaped. ExampleTo create a wildcard expression which searches for any string containing a literal asterisk in an aggregation pipeline, use the following expression:
The first and last asterisks act as wildcards which match any characters, and the NoteUse the following expression to escape a literal backslash:
➤ Use the Select your language drop-down menu to set the language of the examples on this page. ExamplesThe following examples use the TipIf you've already loaded the , follow the tutorial to create an and run Atlas Search queries. Index DefinitionThe following index definition indexes the
The following example searches all The above query returns the following results: The following example searches all The above query returns the following results: Escape Character ExampleThe following example searches for documents in which the NoteThe following example is intended to run in . For more information about using the escape characters with a driver, see The 0 field matches any characters, and the ? 1 string matches a literal question mark. The wildcard 4 stage limits the results to 5 documents, while the wildcard 5 stage limits the results to only the wildcard 7 field. |