In the code above, the search_index()
function specifies the search_item
parameter as "visibility [1-4] mile*" "temperature ? degree*"
. This returns all records that contain both positional phrases, in any order:
"visibility [1-4] mile*"
returns phrases with from 1 to 4 words between the words visibility and mile. Because mile*
specifies a wildcard, it could match either mile or miles, for example:
- visibility less than 1 mile
- visibility 10 miles
- visibility approximately 20 statute miles
- visibility for many miles
- Similarly,
"temp* ? degrees"
returns phrases with a word beginning with temp and ending in 0 or more non-space wildcard characters, a single missing word, and then the word degrees. Thus it would return records with the following phrases:
- temperature 20 degrees
- temp. 20 degrees
- temperature in degrees
"temp* ? degrees"
could also return the phrase temporarily without degrees, which is probably unintended.
This example also highlights the returned text by applying the same search_item
to the returned records, which highlights every instance of either of these phrases by delimiting them with <b> and </b> tags. For example, the query might return a report like the following:
Begin code:End code.
The search_index
function also specifies a few other parameters:
- The
search_index
parameter is the SQL Search index defined earlier, NarrBasicIdx
.
- The
search_option
parameter can apply an optional transformation to the search. Here it is set to the default, 0, meaning no search transformation.
- The
search_language
parameter specifies the default, 'en'
(English).
To learn more about using SQL Search and the different options that you can specify for each parameter, see the resources linked below.