CFLib.org – Common Function Library Project

uCaseWordsForSolr(string)

Last updated August 5, 2011

Version: 1 | Requires: ColdFusion 9 | Library: UtilityLib

 
Rated 1 time(s). Average Rating: 5.0

Description:
Works with SolrClean UDF to UCASE Solr Keywords. Use in conjunction with SolrClean.

Return Values:
Returns a string.

Example:

view plain print about
Works in conjunction with SolrClean. See SolrClean UDF.

Parameters:

Name Description Required
string String to run against Yes

Full UDF Source:

view plain print about
<!---
 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>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Dave Anderson Dave Anderson added
iniToStruct
20 day(s) ago

Dave Anderson Dave Anderson added
deDupeArray
20 day(s) ago

Richard Richard added
dice
22 day(s) ago

Isaac Dealey Isaac Dealey added
getRelative
a while ago

Top Rated

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 22 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Raymond Camden highlightAndCrop
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson