This commit is contained in:
2021-10-11 20:02:05 +00:00
parent 0f8773bde4
commit 697a4ca593

View File

@@ -197,16 +197,18 @@ namespace AyaNova.Biz
//EXACT MATCH SEARCH TERMS
foreach (string Term in SearchTerms)
q.Append($"COUNT(*) FILTER (WHERE asearchdictionary.word = '{Term}') AS 'st{++termCount}', ");
q.Append($"COUNT(*) FILTER (WHERE asearchdictionary.word = '{Term}') AS st{++termCount}, ");
//WILDCARD SEARCH TERMS
foreach (string WildCardSearchTerm in PreWildCardedSearchTerms)
q.Append($"COUNT(*) FILTER (WHERE asearchdictionary.word LIKE '{WildCardSearchTerm}') AS 'st{++termCount}', ");
q.Append($"COUNT(*) FILTER (WHERE asearchdictionary.word LIKE '{WildCardSearchTerm}') AS st{++termCount}, ");
q.Length=q.Length-2;//trim the final comma and space
q.Append("FROM asearchdictionary INNER JOIN asearchkey ON asearchdictionary.id = asearchkey.wordid GROUP BY asearchkey.objectid, asearchkey.atype) SELECT objectid, atype FROM qr WHERE ");
q.Append(" FROM asearchdictionary INNER JOIN asearchkey ON asearchdictionary.id = asearchkey.wordid GROUP BY asearchkey.objectid, asearchkey.atype) SELECT objectid, atype FROM qr WHERE ");
for (; termCount > 0; termCount--)
q.Append($"st{termCount} > 0 {(termCount > 1 ? "AND" : "")}");
q.Append($"st{termCount} > 0 {(termCount > 1 ? "AND " : "")}");
//execute the query and iterate the results