Difference between revisions of "CONTAINS()"
Yvonnemilne (Talk | contribs) |
Yvonnemilne (Talk | contribs) |
||
(6 intermediate revisions by one user not shown) | |||
Line 1: | Line 1: | ||
− | |||
− | |||
==Purpose== | ==Purpose== | ||
− | Function to perform a case-insensitive search of a record's character and ( | + | Function to perform a case-insensitive search of a record's character and memo (optional) fields for a specified character string |
Line 10: | Line 8: | ||
==See Also== | ==See Also== | ||
− | [[CHROVERLAP()]], [[EMPTY()]], [[EVALUATE()]], [[EXPRCHECK()]], [[FOR()]], [[INDEX]], [[INLIST()]], [[INRANGE()]], [[ISALPHA()]], [[ISBLANK()]], [[ISDIGIT()]], [[MAX()]], [[MAXVALUES()]], [[MIN()]], [[MINVALUES()]], [[TYPE()]], [[VARTYPE()]] | + | [[BETWEEN()]], [[CHROVERLAP()]], [[EMPTY()]], [[EVALUATE()]], [[EXPRCHECK()]], [[FOR()]], [[INDEX]], [[INLIST()]], [[INRANGE()]], [[ISALPHA()]], [[ISBLANK()]], [[ISDIGIT()]], [[LOWER()]], [[MAX()]], [[MAXVALUES()]], [[MIN()]], [[MINVALUES()]], [[MTOS()]], [[PROPER()]], [[Relational Operators]], [[SEEK]], [[SEEK()]], [[TYPE()]], [[UPPER()]], [[VARTYPE()]] |
Line 16: | Line 14: | ||
The CONTAINS() function returns .T. (True) if the current record contains the specified character string, <expC>. | The CONTAINS() function returns .T. (True) if the current record contains the specified character string, <expC>. | ||
− | A case-insensitive search is performed on the current record's character fields. If the optional <expL> is .T. (True) or the optional <expN> is 1, memo fields are also | + | A case-insensitive search is performed on the current record's character fields. If the optional <expL> is .T. (True) or the optional <expN> is 1, memo fields are also checked, otherwise they are excluded from the search. |
Line 24: | Line 22: | ||
|<expC>||The character string to search for. | |<expC>||The character string to search for. | ||
|- | |- | ||
− | |<expL>||. | + | |<expL>||If .T. (True), memos are included in the search. |
|- | |- | ||
− | |<expN>||. | + | |<expN>||If 1, memos are included in the search. |
|- | |- | ||
|} | |} | ||
+ | |||
+ | |||
+ | The CONTAINS() function is particularly useful in creating full text-search indexes, as shown in the example below. | ||
Line 34: | Line 35: | ||
<code lang="recital"> | <code lang="recital"> | ||
open database southwind | open database southwind | ||
− | use | + | use products |
− | // Restrict index to records with a character field containing string " | + | // Restrict index to product records in category 2 (condiments) with a character field containing string "bottled", memos excluded |
− | index on lower( | + | index on lower(productname) for contains("bottles",.F.) and categoryid = 2 tag bottled |
</code> | </code> | ||
Line 46: | Line 47: | ||
[[Category:Expressions and Type Conversion]] | [[Category:Expressions and Type Conversion]] | ||
[[Category:Expressions and Type Conversion Functions]] | [[Category:Expressions and Type Conversion Functions]] | ||
+ | [[Category:Indexing]] | ||
+ | [[Category:Indexing Functions]] |
Latest revision as of 13:59, 14 June 2011
Purpose
Function to perform a case-insensitive search of a record's character and memo (optional) fields for a specified character string
Syntax
CONTAINS(<expC>,[<expL>|<expN>])
See Also
BETWEEN(), CHROVERLAP(), EMPTY(), EVALUATE(), EXPRCHECK(), FOR(), INDEX, INLIST(), INRANGE(), ISALPHA(), ISBLANK(), ISDIGIT(), LOWER(), MAX(), MAXVALUES(), MIN(), MINVALUES(), MTOS(), PROPER(), Relational Operators, SEEK, SEEK(), TYPE(), UPPER(), VARTYPE()
Description
The CONTAINS() function returns .T. (True) if the current record contains the specified character string, <expC>.
A case-insensitive search is performed on the current record's character fields. If the optional <expL> is .T. (True) or the optional <expN> is 1, memo fields are also checked, otherwise they are excluded from the search.
Parameters | Description |
---|---|
<expC> | The character string to search for. |
<expL> | If .T. (True), memos are included in the search. |
<expN> | If 1, memos are included in the search. |
The CONTAINS() function is particularly useful in creating full text-search indexes, as shown in the example below.
Example
open database southwind use products // Restrict index to product records in category 2 (condiments) with a character field containing string "bottled", memos excluded index on lower(productname) for contains("bottles",.F.) and categoryid = 2 tag bottled
Products
Recital Server, Recital