uCaseWordsForSolr(string)
Last updated August 5, 2011
Version: 1 | Requires: ColdFusion 9 | Library: UtilityLib
Description:
Works with SolrClean UDF to UCASE Solr Keywords. Use in conjunction with SolrClean.
Return Values:
Returns a string.
Example:
Parameters:
| Name | Description | Required |
|---|---|---|
| string | String to run against | Yes |
Full UDF Source:
<!---
Works with SolrClean UDF to UCASE Solr Keywords.
@param string String to run against (Required)
@return Returns a string.
@author Sami Hoda (sami@bytestopshere.com)
@version 1, August 5, 2011
--->
<cffunction name="uCaseWordsForSolr" access="public" output="false" returntype="Any" >
<cfargument name="string" type="string" default="" required="true" hint="String to run against" />
<cfargument name="listOfWords" type="string" default="AND,OR,NOT,TO" required="false" hint="Comma-delim list of words to uCase" />
<cfset var sLocal = StructNew() />
<cfset sLocal.newString = lcase(arguments.string) /> <!--- lcase by default. mixed-case treated as case-sensitive by Solr --->
<cfset sLocal.i = "" />
<cfloop list="#arguments.listOfWords#" index="sLocal.i">
<cfset sLocal.newString = reReplaceNoCase(sLocal.newString, "([^a-z])(#sLocal.i#)([^a-z])", "\1#ucase(sLocal.i)#\3", "all")/>
</cfloop>
<cfreturn sLocal.newString />
</cffunction>
Search CFLib.org
Latest Additions
Dave Anderson added
iniToStruct
20 day(s) ago
Dave Anderson added
deDupeArray
20 day(s) ago
Richard added
dice
22 day(s) ago
Isaac Dealey added
getRelative
a while ago
Top Rated
backupDatabase
Rated 5.0, 22 time(s)
indentXml
Rated 5.0, 10 time(s)
generateSsccAsn
Rated 5.0, 4 time(s)
highlightAndCrop
Rated 5.0, 4 time(s)