Show / Hide Table of Contents

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.

Inheritance
Object
FreetextMatchCalculator
Namespace: SuperOffice.CRM.ArchiveLists
Assembly: SoDataBase.dll
Syntax
public static class FreetextMatchCalculator : Object

Methods

CalculateMatches(String[], String[], Nullable<Int32>, Nullable<Int32>, Boolean, List<PartialMatches>, Boolean)

Perform a freetext search and return the ids of the matching owners

Declaration
public static Dictionary<int, List<int>> CalculateMatches(string[] wordList, string[] owners, Nullable<int> searchOp = null, Nullable<int> hitLim = null, bool soundex = false, List<PartialMatches> partialMatches = null, bool strictSearch = false)
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"]

Nullable<Int32> searchOp

Override search operator: 1 = contains, 2 = starts with, 3 = exact match. Default to preference values

Nullable<Int32> hitLim

Max number results to return. Defaults

Boolean soundex

Should we do SOUNDEX words instead of normal words?

List<PartialMatches> partialMatches

External storage for partial results

Boolean strictSearch

If true, then search main table only, not text or udefs

Returns
Type Description
Dictionary<Int32, List<Int32>>

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<Int32, List<Int32>>)

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<Int32, List<Int32>> matches
Returns
Type Description
Dictionary<Int32, Int32>

TableNumberToLocalizedName(Int32)

Map the knwon, standard freetext owner entities into localized resources names

Declaration
public static string TableNumberToLocalizedName(int tableNumber)
Parameters
Type Name Description
Int32 tableNumber
Returns
Type Description
String
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top