svySearch
Last updated
Was this helpful?
Last updated
Was this helpful?
Welcome to the svySearch wiki! This wiki provides comprehensive documentation to using the svySearch module. This module is designed to parse natural-language text input and apply it to developer-specified patterns for searching.
Table of Contents
Text is parsed according to some general patterns. String fragments are matched against developer-specified , which map some rules to how certain columns are searched.
Patterns
: Parsing input for individual words
: Used to escape token separators
: Used to explicitly referenes a single
: For comparisons other than the default LIKE/Contains
: Dynamically match and replace input text, ideal for converting value list values into stored values
Example
NOTE: Multiple tokens that match on the same related SearchProvider are not currently supported and may result in no records. This cannot be easily supported, because when a SearchProvider is compared to multiple tokens, we cannot know which token(s) matched, and therefore, cannot guarantee the contract for matching ALL tokens.
Use double quotes to escape tokenization
Example
Example
By default, all searches are LIKE/Contains for Strings and strict "=" for Numbers and Dates. However, additional operators may be specified at the beginning of a token (except for the BETWEEN operator)
-
Exclude
Excludes the token from the search using a NOT LIKE for Strings and NOT EQUAL for Numbers and Dates
+
Exact
Performs an exact match in lieu of a LIKE
>
Greater-Than
Matches all values greater than the specified token
>=
Greater-Than-Or-Equal
Matches all values greater than or equal to the specified token
<
Less-Than
Matches all values less than the specified token
<=
Less-Than-Or-Equal
Matches all values less than or equal to the specified token
...
Between
Matches all values between the two operands
Example
Substitutions can be applied dynamically to match and replace string fragments within user input. This is ideal for allowing users to express custom ValueList display values in their searches, and have those values resolved to the actual stored/DB value
Example
svySearch is an object-oriented API for parsing user input and applying searches against the data model.
Example
A single scope that contains the classes
Params
Number
dataSource
The data source used
Required
returns
example
A class which models a search on a particular data source and its supporting class
Add alternative date format which is used to parse user input for searching dates in addition to the default format.
Adds a dataprovider to the search object.
Get all search providers for this search object
Returns the alternate date format which is used to parse user input for searching dates in addition to the default format.
Returns the data source used by the search object
Returns the date format which is used to parse user input for searching dates
Creates a factory foundset, runs the search and returns it
Creates and returns a query object parsed from the user input
Gets the raw, unparsed input text
Loads records on the specified foundset.
Remove alternative date format which is used to parse user input for searching dates in addition to the default format.
Sets the date formatting which will be used to parse user input
Sets that all columns are to be searchable
Set the raw, user input to be parsed
Add alternative date format which is used to parse user input for searching dates in addition to the default format.
Params
format
any date format pattern that will result in a well defined time interval to search for (e.g. MM-yyyy will look for beginning of month to end of month)
Required
Example
Adds a search provider to the search object.
Params
dataProviderID
The data provider that will be searched. Can be columns, related columns
Required
alias
The natural language name of the search provider. Used in explicit searches.
Optional. Default is same as data provider
impliedSearch
Set this false to indicate that a provider is not searchable unless explicitly referenced
Optional. Default is True
caseSensitive
Set this to be true to force case-sensitive search on this search provider
Optional. Default is False
Get all search providers for this search object
Returns the alternate date format which is used to parse user input for searching dates in addition to the default format.
Params
Number
maxRows
The max rows to retrieve
Optional. Default is -1 (unlimited)
Returns the data source used by the search object
Returns the date format which is used to parse user input for searching dates
Creates a factory foundset, runs the search and returns it
Creates and returns a query object parsed from the user input
Params
aliasOrDataProvider
The name or alias of the data provider
Required
Gets the raw, unparsed input text
Loads records in the specified foundset
Params
foundSet
Required
Remove alternative date format which is used to parse user input for searching dates in addition to the default format.
Params
format
the alternate date format to be removed
Required
Sets the date formatting which will be used to parse user input
Params
format
The format to use for date searches
Required
Sets that all columns are to be searchable
This should be called before adding any additional, related search providers
Set the raw, user input to be parsed
Params
searchText
The raw text to be parsed
Required
A class which models the component of the search that maps to a single data provider.
Add a substitution kev-value pair to this search provider
Gets the alias of this search provider.
Gets the data provider ID
JSColumn
Get the JSColumn object that corresponds to this search provider
JSTable
Get the JSTable object that corresponds to this search provider
Get all the keys for substitutions
Get the substitution value for a given key
Specifies if this search provider is included in implied search
Add a substitution kev-value pair to this search provider
Substitutions provide replacement capability for user input.
A typical use case involves parsing a value list display value
Params
key
A string to be replaced
Required
value
The value to replace it with
Required
Gets the alias of this search provider.
Gets the data provider ID
Get the JSColumn object that corresponds to this search provider
Returns JSColumn
Get the JSTable object that corresponds to this search provider
Returns JSTable
Get the matching mode for this search provider.
Get all the keys for substitutions
Get the substitution value for a given key
Params
key
The substitution key
Required
Returns [Boolean]
The alias can be used in explicit searches
Params
alias
The alias
Required
Params
caseSensitive
The value for case-sensitive
Required
Params
castInteger
True if the INTEGER values should cast to TEXT
Required
Specifies if this search provider is included in implied search
A value of true indicates that the provider will always be searched
A value of false indicates that provider will ONLY be searched when used in explicit field matching
Params
impliedSearch
The value for implied search
Required
Sets the string matching mode for this SearchProvider
Params
stringMatching
The desired matching mode
Required
Words separated by white space will be treated as separate tokens. ALL tokens must match ANY .
Any can be explicitly searched using the data provider name or alias. Aliases are specified left or a ':' character. Additionally, some can be specified as explicit-only, meaning the field is not searched unless the user performs an alias-based search. This can be useful for date fields
The API consists of the primary class , which models a search on a particular data source and its supporting class, , which models th ecomponent of the search that maps to a single data provider.
<>
<String>
Executes the search and returns the results as a
Gets a by specified name (alias)
Returns
Returns
Returns <>
Returns <String>
Executes the search and returns the results as a
Returns
Returns
Returns
Returns
Returns
Gets the specified
Returns or null if named is not found
Returns
The object upon which to load records
Returns True indicates query was successful, although may have loaded zero records
Returns
Returns Returns this for convenience, method chaining
Returns Returns this for convenience, method chaining
Returns Returns this for convenience, method chaining
gets the String matching mode for this
<>
Indicates if this is case-sensitive
Indicates if this will cast INTEGER to TEXT
Indicates if this is an implied search
Sets the natural language name for this
Specifies if this will perform case-sensitive searches
Specifies if this will cast INTEGER to TEXT
Sets the String matching mode for this
Returns this for convenience, method chaining
Returns The alias, or null if none was specified
Returns The data provider which will be searched
Returns
Returns <>
Returns
Indicates if this is case-sensitive
Returns
Indicates if this will cast INTEGER values to TEXT in the query
Indicates if this is an implied search
Returns
Sets the natural language name for this
Returns this for convenience, method chaining
Specifies if this will perform case-sensitive searches
Returns this for convenience, method chaining
Specifies if this will cast INTEGER values to TEXT in the query. For example, a search term "1025"
would match on 10250
, 10251
, 91025
, etc.
Returns this for convenience, method chaining
Returns this for convenience, method chaining
Returns this for convenience, method chaining