This is an old revision of the document!
Overview | Example | SQL | Optimization | Customization | Tips
In most scenarios, the key to implementing PowerSearch is to simply use the POWERSEARCH option on a SELECT statement. Alternatively, the SET POWERSEARCH ON command can be used to automatically activate PowerSearch for all queries on that connection.
The POWERSEARCH option works hand-in-hand with the data stored in the Omnidex Environment File. To use POWERSEARCH, administrators add a context to columns telling Omnidex what they contain. For example, a column named FIRST_NAME may have a character datatype, but that alone is not enough to tell Omnidex what the column contains. Moreover, Omnidex cannot look to the column name, as there are many different conventions for naming columns. Administrators add a USAGE clause that identifies the contents as given names, as shown in this example:
create table "HOUSEHOLDS" physical "dat\households.dat" ( "HOUSEHOLD" CHARACTER(12) omnidex, "ADDRESS" CHARACTER(50) quicktext usage "STREET_ADDRESS", "CITY" CHARACTER(28) quicktext usage "CITY", "STATE" CHARACTER(2) omnidex usage "STATE", "ZIP" CHARACTER(5) omnidex usage "ZIPCODE", "COUNTRY" CHARACTER(2) omnidex usage "COUNTRY", constraint HOUSEHOLDS_HOUSEHOLD_PK primary ("HOUSEHOLD"), constraint HOUSEHOLDS_STATE_FK foreign ("STATE") references "STATES", constraint HOUSEHOLDS_COUNTRY_FK foreign ("COUNTRY") references "COUNTRIES" ) in "simple.xml"; create table "INDIVIDUALS" physical "dat\individuals.dat" ( "INDIVIDUAL" CHARACTER(12) omnidex, "HOUSEHOLD" CHARACTER(12) omnidex , "NAME" CHARACTER(50) quicktext usage "NAME", "GENDER" CHARACTER(1) omnidex bitmap, "BIRTHDATE" ANSI DATE omnidex, "PHONE" CHARACTER(14) omnidex usage "PHONE", "EMAIL" CHARACTER(60) quicktext usage "EMAIL", constraint INDIVIDUALS_INDIVIDUAL_PK primary ("INDIVIDUAL"), constraint INDIVIDUALS_HOUSEHOLD_FK foreign ("HOUSEHOLD") references "HOUSEHOLDS", constraint INDIVIDUALS_GENDER_FK foreign ("GENDER") references "GENDERS", ) in "simple.xml";
Once these usages are applied, the POWERSEARCH option automatically expands the search:
Without the PowerSearch option: WITH the POWERSEARCH option:
SALUTATION FIRST_NAME MIDDLE_NAME LAST_NAME NAME COMPANY_NAME STREET_NUMBER STREET_DIRECTION STREET_NAME STREET_TYPE UNIT_TYPE UNIT_NUMBER CITY STATE COUNTRY ZIPCODE STREET_ADDRESS CITY_STATE_POSTAL ADDRESS PHONE_AREACODE PHONE_PREFIX PHONE_SUFFIX PHONE EMAIL
the $CONTAINS function in Omnidex SQL. This function provides access to most of the search capabilities shown on the previous page.
The $CONTAINS function is used in the WHERE clause of a SELECT statement to provide criteria accompanied by special options. In traditional SQL statements, criteria is specified using a syntax of:
SELECT COUNT(*) FROM LIST WHERE FNAME = 'Bill';
The $CONTAINS function allows this same statement to be reworded as follows:
SELECT COUNT(*) FROM LIST WHERE $contains(FNAME, 'Bill');
The real advantage of the $CONTAINS function lies in the options that can be added. The $CONTAINS function is discussed in depth in the documentation on the function. Meanwhile, the following examples show how the options were used to provide each of the capabilities shown on the previous page.
PowerSearch uses a given names synonym list to search for both the formal given name and the most common variations. For example:
Given Name | Synonyms |
---|---|
William | Bill, Billy, Will, Williams, Willie, Willis, Wilson |
James | Jim, Jimmy, Jimmie, Jay, Jaime, Jacob |
Elizabeth | Beth, Betty, Eliza, Elsa, Lisa, Liz, Liza |
Ann | Ana, Anita, Anna, Anne, Annette, Annie, Annmarie |
The SQL syntax for given name synonyms searches is shown below.
SELECT ... FROM ... WHERE $contains(FNAME, 'Bill', 'SYNONYMS=ALL_GIVEN_NAMES') ...
PowerSearch uses phonetic algorithms to search for last names that sound similar, but are spelled differently.
Here are some examples:
Last Name | Phonetic Equivalents |
---|---|
Smith | Schmit, Schmidt, Schmitt, Smidt, Smit, Smith, Smithey, Smyth, Smythe |
Meyers | Meyers, Myers, Myres, Meiers, Moyers, Meers, Mayers, Maris |
Nelson | Nelsen, Nielsen, Nielson, Neilsen, Neilson, Nilsen, Nilson, Nilsson |
Williams | Willaims, Wiliams, Willimas, Wilmes, Willams, Willems |
The SQL syntax for phonetic last name searches is shown below. Note that phonetic searches require an index that uses the PHONETIC option.
SELECT ... FROM ... WHERE $contains(LNAME, 'Meyers', 'PHONETIC') ...
PowerSearch uses a postal abbreviations synonym list, combined with misspelling and transposition algorithms, to search street addresses.
Here are some examples:
Category | Search Term | Equivalents |
---|---|---|
Street Types | Ave, St, Blvd | Avenue, Street, Boulevard |
Street Directions | N, S, E, W | North, South, East, West |
Street Names (abbreviated) | 1st, 2nd, 3rd, 4th, 5th | First, Second, Third, Fourth, Fifth |
Street Names (misspelled) | Canterbury | Cantaberry, Canterbury, Cantabury |
Unit Types | Apt, Ste, Rm | Apartment, Suite, Room |
Street Numbers | 12345 | 13245, 15324, 1234, 2345 |
The SQL syntax for postal abbrevation synonym searches and misspelling searches is shown below.
SELECT ... FROM ... WHERE $contains(ADDRESS1, '825 Fifth Avenue', 'SYNONYMS=ALL_ADDRESS_LINES,MISSPELLINGS') ...
PowerSearch uses a cities synonym list, combined with misspelling algorithms, to search city names. For example:
Category | Search Term | Equivalents |
---|---|---|
Abbreviations | SF, LA, NY | San Francisco, Los Angeles, New York |
Misspellings | Milwaukee | Milwalkee, Milwauki, Milwalke |
The SQL syntax for city synonym searches and misspelling searches is shown below.
SELECT ... FROM ... WHERE $contains(CITY, 'NY', 'SYNONYMS=CITY_ABBR,MISSPELLINGS') ...
PowerSearch uses a geographic radius search to locate zip codes that are within a certain distance from the named zip code. This is an example of a PowerSearch search that does not use the $CONTAINS function. Instead, it uses the $DISTANCE function to perform the radius search. This search requires that the database have a table of postal codes that includes their geographic coordinates.
Here are some examples:
Zip Code | Adjacent Zip Code | Distance |
---|---|---|
10021 | 10162 10155 10028 10044 10052 10022 | .48 miles .64 miles .67 miles .73 miles .80 miles .82 miles |
The SQL syntax for zip code geographic radius searches is shown below.
SELECT ... FROM ... WHERE ZIP IN (SELECT ZIP FROM ZIPCODES WHERE $distance((SELECT LATITUDE, LONGITUDE FROM ZIPCODES WHERE ZIP = '10022'), LATITUDE, LONGITUDE) <= 5) ...
PowerSearch uses an area code synonym list to locate area codes that are shared within the same metropolitan area.
Here are some examples:
Metropolitan Area | Area Codes |
---|---|
New York, NY | 212, 646, 917 |
Denver, CO | 303, 720 |
Seattle, WA | 206, 360, 253, 425, 564 |
The SQL syntax for telephone area code synonym searches is shown below.
SELECT ... FROM ... WHERE $contains(PHONE1_AREA, '917', 'SYNONYMS=AREACODES') ...
PowerSearch uses a transposition search to locate telephone numbers that have been transposed or mistyped.
Here are some examples:
Phone Number | Transposition |
---|---|
775-4866 | 755-4846 |
831-6584 | 381-8564 |
The SQL Syntax for telephone number transposition searches is shown below.
SELECT ... FROM ... WHERE $contains(PHONE1_PREFIX, '755', 'MISSPELLINGS MIN_SCORE=70') AND $contains(PHONE1_SUFFIX, '4686', 'MISSPELLINGS MIN_SCORE=70') ...
PowerSearch uses a standard misspelling search to locate email addresses that have similar spellings. The SQL syntax for email misspelling searches is shown below.
SELECT ... FROM ... WHERE $contains(EMAIL, 'wmeyers@med.cornell.edu', 'MISSPELLINGS MIN_SCORE=80') ...
When combined, the final SQL statement has many $CONTAINS functions which combine to provide the full power of PowerSearch:
SELECT COUNT(*) FROM LIST WHERE $contains(FNAME, 'Bill', 'SYNONYMS=ALL_GIVEN_NAMES') AND $contains(LNAME, 'Meyers', 'PHONETIC') AND $contains(ADDRESS1, '825 Fifth Avenue', 'SYNONYMS=ALL_ADDRESS_LINES,MISSPELLINGS') AND $contains(CITY, 'NY', 'SYNONYMS=CITY_ABBR,MISSPELLINGS') AND LIST.STATE = 'NY' AND ZIP IN (SELECT ZIP FROM ZIPCODES WHERE $distance((SELECT LATITUDE, LONGITUDE FROM ZIPCODES WHERE ZIP = '10022'), LATITUDE, LONGITUDE) <= 5) AND $contains(PHONE1_AREA, '917', 'SYNONYMS=AREACODES') AND $contains(PHONE1_PREFIX, '755', 'MISSPELLINGS MIN_SCORE=70') AND $contains(PHONE1_SUFFIX, '4686', 'MISSPELLINGS MIN_SCORE=70') AND $contains(EMAIL, 'wmeyers@med.cornell.edu', 'MISSPELLINGS MIN_SCORE=80');
See also: