({{, (RefLink[SearchQueryString, paclet:ref/SearchQueryString])["query"] 
represents a search engine-style query in (RefLink[TextSearch, paclet:ref/TextSearch]) and related functions.}})

OpenersNotesSection(Spacer1)Details

The following can be used within the query:

The following additional and alternate forms are also supported:

OpenersPrimaryExamplesSection(Spacer1)Examples  (8)

OpenersExampleSection0(Spacer1)Basic Examples  (6)

Match an exact phrase:

index = CreateSearchIndex["ExampleData/Text"];
TextSearch[index, SearchQueryString["\"which I now\""]][All]

A sequence of terms is interpreted as (RefLink[ContainsAll, paclet:ref/ContainsAll]) by default:

index = CreateSearchIndex["ExampleData/Text"];
TextSearch[index, SearchQueryString["dog rabbit"]][All]

Search in a particular field:

index = CreateSearchIndex["ExampleData/Text"];
TextSearch[index, SearchQueryString["FileName:Alice"]][All]

Require "dog" but disallow "Alice":

index = CreateSearchIndex["ExampleData/Text"];
TextSearch[index, SearchQueryString["+dog -Alice"]][All]

A Boolean query where the weight of "lorem" is reduced:

index = CreateSearchIndex["ExampleData/Text"];
TextSearch[index, SearchQueryString["(dog NOT Alice) OR lorem^0.01"]][All]

Hyphenated words in queries match only the documents where the words appear both contiguously and in the same order:

index=CreateSearchIndex[{
<|"Title"->"doc1","Text" -> "Here is Paul's mother in law."|>,
<|"Title"->"doc2","Text" -> "My mother never broke the law in her entire life."|>
}];
TextSearch[index, SearchQueryString["mother-in-law"],"Count"]

TextSearch[index, SearchQueryString["mother in law"],"Count"]

OpenersExampleSection2(Spacer1)Possible Issues  (2)

Wildcard searches interact with stemming, so "ali?" matches but "alic?" does not:

index = CreateSearchIndex["ExampleData/Text"];
TextSearch[index, SearchQueryString["ali?"]][All]

TextSearch[index,SearchQueryString["alic?"]][All]

(RefLink[SearchQueryString, paclet:ref/SearchQueryString]) can only be used when searching on an index:

TextSearch[File["ExampleData/Text"], SearchQueryString["dog rabbit"]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[TextSearch, paclet:ref/TextSearch])  ▪  (RefLink[SearchAdjustment, paclet:ref/SearchAdjustment])  ▪  (RefLink[RegularExpression, paclet:ref/RegularExpression])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Text Search, paclet:guide/TextSearch])}})}})