Class FreetextMatchCalculator
This is a utility class to perform an actual freetext search, for single or multiple words. It returns sets of ids that indicate the matches, and can also consolidate such sets into counts.
Inherited Members
Namespace: SuperOffice.CRM.ArchiveLists
Assembly: SoDataBase.dll
Syntax
public static class FreetextMatchCalculator
Methods
CalculateMatches(string[], string[], int?, int?, bool, List<PartialMatches>)
Perform a freetext search and return the ids of the matching owners
Declaration
public static Dictionary<int, List<int>> CalculateMatches(string[] wordList, string[] owners, int? searchOp = null, int? hitLim = null, bool soundex = false, List<PartialMatches> partialMatches = null)
Parameters
Type | Name | Description |
---|---|---|
string[] | wordList | Array of words to search for, with an implicit AND between them: ["foo", "bar"] |
string[] | owners | Array of owner table names to search: ["contact", "sale"] |
int? | searchOp | Override search operator: 1 = contains, 2 = starts with, 3 = exact match. Default to preference values |
int? | hitLim | Max number results to return. Defaults |
bool | soundex | Should we do SOUNDEX words instead of normal words? |
List<PartialMatches> | partialMatches |
Returns
Type | Description |
---|---|
Dictionary<int, List<int>> | Dictionary indexed by owner entity table number; value is a dictionary of ids (with no subvalues, the dictionary class is used to ensure a unique id list) |
Remarks
Search words are first matched against the stopword list and stopwords removed. If no valid words are left, the search terminates with 0 matches. Then, a match id list is built for each word, and the intersection of the lists calculated. The search terminates when all words have been processed, or when the intersection is empty.
Normal (non-cross table) search: all words must be found with-in a given owner. e.g. Search for "Foo bar" can find "Foo" in the contact.name and "bar" in the address table of the same contact. Cross-table search: all words do not have to be found within a given owner. e.g. Search for "Foo bar" can find "Foo" in a contact, and "Bar" in a person record. The client needs to join the contact and person results to get the final results. Results are returned in two buckets: Pure results (all words found in entity) as the table number, and Partial results (some words found in entity) as the negative table number.GroupMatches(Dictionary<int, List<int>>)
Consolidate a match list dictionary into a dictionary of owner table ids and counts
Declaration
public static Dictionary<int, int> GroupMatches(Dictionary<int, List<int>> matches)
Parameters
Type | Name | Description |
---|---|---|
Dictionary<int, List<int>> | matches |
Returns
Type | Description |
---|---|
Dictionary<int, int> |
TableNumberToLocalizedName(int)
Map the knwon, standard freetext owner entities into localized resources names
Declaration
public static string TableNumberToLocalizedName(int tableNumber)
Parameters
Type | Name | Description |
---|---|---|
int | tableNumber |
Returns
Type | Description |
---|---|
string |