Class TextSearchQueryBuilder
Class for building dynamic SQL text search queries.
Inheritance
Inherited Members
Namespace: EPiServer.Core.Html
Assembly: EPiServer.dll
Version: 8.11.0Syntax
[Obsolete("indexing is now handled through the Indexing Service")]
public class TextSearchQueryBuilder
Constructors
TextSearchQueryBuilder()
Declaration
public TextSearchQueryBuilder()
Methods
BuildDynamicSearchQuery(TextSearchParameters)
Create a dynamic SQL query that has the following format:
If there are one or more mandatory words (+ prefix) in the query:
SELECT fkPageID, sum(k1.Rank + k2.Rank + ...) as Rank FROM tblPage p INNER JOIN usrPageKeywordViewWithRanks k1 ON k1.pkid=pkid AND k1.Keyword LIKE @Keyword1 INNER JOIN usrPageKeywordViewWithRanks k2 ON k2.pkid=pkid AND k2.Keyword LIKE @Keyword2 ... more joins GROUP BY pkid ORDER BY Rank DESC
If there are no mandatory words, but one or more optional words (no +/- prefix):
SELECT fkPageID, sum(Rank) as Rank FROM usrPageKeywordViewWithRanks p WHERE (Keyword LIKE @Keyword1+'%' OR Keyword LIKE @Keyword2+'%' OR ...)
If there are one or more exclude words (- prefix), add the following to the WHERE clause:
AND ("AND" only inserted if there are previous WHERE statements) fkPageID NOT IN (SELECT * FROM usrPageKeywordView p WHERE Keyword LIKE @Keyword3+'%' OR Keyword LIKE @Keyword4+'%' OR ...)
Declaration
public static DynamicSQLQuery BuildDynamicSearchQuery(TextSearchParameters searchParams)
Parameters
Type | Name | Description |
---|---|---|
TextSearchParameters | searchParams | An instantiated TextSearchParameters object that contains the search words |
Returns
Type | Description |
---|---|
DynamicSQLQuery | A string containing the SQL query |
CreateSpParamName(Int32)
Helper function for creating a stored procedure parameter name from a keyword's unique index in the TextSearchParameters object where the keyword is stored.
Declaration
public static string CreateSpParamName(int uniqueKeywordIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | uniqueKeywordIndex | A unique keyword index between 1..keyword count |
Returns
Type | Description |
---|---|
System.String | Keyword name as a SQL SP parameter, for eg. @Keyword2 |
EncodeSQLWildcards(String)
Declaration
public static string EncodeSQLWildcards(string paramValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | paramValue |
Returns
Type | Description |
---|---|
System.String |
ListArrayJoin(ArrayList, String)
Declaration
public static string ListArrayJoin(ArrayList list, string separator)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.ArrayList | list | |
System.String | separator |
Returns
Type | Description |
---|---|
System.String |
ListArrayJoin(ArrayList, String, String)
Concatenates a specified separator string between each element of a specified ArrayList object, yielding a single concatenated string.
Declaration
public static string ListArrayJoin(ArrayList list, string separator, string preText)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.ArrayList | list | ArrayList containing strings |
System.String | separator | A string that is concatenated between each element. |
System.String | preText | An optional string that is inserted in front of each element. |
Returns
Type | Description |
---|---|
System.String | A string containing the joined elements. |