Text functions


Examples of textsearch queries

Note all the below queries can be used as a parameter to the textsearch function.

{ OR : "Moon Walk" } # Search for all documents that contain either Moon or Walk { AND : "Moon Wa" } # Search for all documents that contain the word "moon" and any word starting with "wa". The search engine automatically treats all terms in the query as prefixes. { NOT : { OR : "Moon Walk" } # Search for all documents that contain neither Moon nor Walk { AND : "Moon Walk" } # Search for all documents that contain Moon and Walk { OR : [ { AND : "Moon Walk" }, { AND : "Harlem Shake" } ] } # Search for all documents that contain Moon AND Walk OR Harlem AND Shake { NOT : [ { AND : "Moon Walk" }, { AND : "Harlem Shake" } ] } # Search for all documents that contain neither Moon AND Walk nor Harlem AND Shake { ATLEAST : "3d tv touch screen", ratio : 0.5 } # Search for all documents that contain at least two terms in "3d tv touch screen" Documents which contain more terms in the set are ranked higher { ANY : [ { PHRASE : "Moon Walk" }, { AND : "Moon Walk" } ] } # Search for documents which contain the phrase "Moon Walk". if no matches are found, search for documents that contain both "Moon Walk" but not as a phrase { PHRASE : "Past and present" } # Search for all documents that contain the phrase "Past and present" { AND : [ { phrase : "Past and present" }, "Lecture" ] } # Search for all documents that contain the phrase "Past and present" and the term "Lecture" # Consider the below indexed document: { name : "John Aaron Smith" } { PHRASE : "John Smith", GAP : 2 } # A phrase search using "John Smith" will not match any documents. However using the gap operator of 2, "John Smith" will match "John Aaron Smith" { PHRASE : "Smith John", GAP : -2 } # What about the case when the search input is "Smith John"? Using a negative $gap value will match "John Aaron Smith" { OR : "Oister", FUZZY : 1 } # Perform a fuzzy search by using the fuzzy attribute in any textquery. A value greater than 1 specifies the edit distance. When the edit distance specified is zero, the search engine will use an edit distance of 1 for terms less than or equal to 5 characters and an edit distance of 2 for terms with more than 5 characters. You can specify a negative edit distance. A negative value is first converted to a positive value and then divided by the number of characters in a term to derive the edit distance. That is if you specify an edit distance of -4, terms with 4 or less characters will have an edit distance of 1, 2 for terms between 5 and 8 characters and 3 for terms between 9 and 12.