Copy link to clipboard
Copied
OK. One last item to cure with respect to applicant searches.
In CF 4.51 the collection for applicants was based on a huge folder containing .txt files.
In CF 2023 the colleciton is based on a huge folder containg: .doc, .docx, .pdf & .txt files.
The code that worked against the .txt file collection was.
****************************
values (#getCurrentSearchID.theSearchID#, #Replace( replace( URL, "/", "" ), ".txt", "" )#)
****************************
Basically, it stripped off the .txt part of the file name & the "/" that solr inserts into the value of URL> so that we are left with the file # to use in further processing.
I have tried the following against the folder with the 4 extensions mentioned above.
***************************
values (#getCurrentSearchID.theSearchID#, #Replace( replace( URL, "/", "" ), (".doc" or ".docx" or ".txt") ", "" )#)
***************************
CF is not happy with my (".doc" or ".docx" or ".txt") construct. Would very much appreciate any suggestions. Would like to avoid CFIF/CFELSE searching each URL returned to see which extension is involved before continuing to process the data, if that is even possible.
Simple as pie:
ReplaceNoCase(ReplaceNoCase(ReplaceNoCase(ReplaceNoCase( replace( URL, "/", "" ), ".doc", "" ), ".docx", "" ), ".txt", "" ), ".pdf", "" )
Copy link to clipboard
Copied
Is this what you're looking for? Replacing all those extensions in one line?
Replace(Replace(Replace( replace( URL, "/", "" ), ".doc", "" ), ".docx", "" ), ".txt", "" )
Copy link to clipboard
Copied
Hmm ...
So what this will do is search for all of them and only delete the one that actually exists AND NOT produce an error for those extensions that are not in the URL. I"ll need to add one more for the .pdf files as well. Does this look right to you?
Replace(Replace(Replace(Replace( replace( URL, "/", "" ), ".doc", "" ), ".docx", "" ), ".txt", "" ), ".pdf", "" )
Copy link to clipboard
Copied
That's correct. If there is no 'docx' to replace, it just moves on to .txt, then .pdf. No errors.
Might not be the most elegant line of code ever, but gets the job done.
Alternatively, I guess you could use listEach():
<cfset theString = replace( URL, "/", "" )>
<cfset alist = ".doc,.docx,.txt,.pdf">
<cfset listEach(alist,function(idx){
theString = replace(theString,idx,'');
})>
Copy link to clipboard
Copied
Your suggestion works! However, there is one wrinkle. It is case sensitive. Resumes are entered into the system by individual candidates some of whom used upper case (e.g. ".DOC"). I can add four more extensions. But there is always the possibility of outliers like .Doc.
I don't suppose there is anyway to drive the string case-insensitive? 😉
Please advise. Thanks.
Copy link to clipboard
Copied
Simple as pie:
ReplaceNoCase(ReplaceNoCase(ReplaceNoCase(ReplaceNoCase( replace( URL, "/", "" ), ".doc", "" ), ".docx", "" ), ".txt", "" ), ".pdf", "" )
Copy link to clipboard
Copied
You win the GOLD STAR!!
Thank you very much.
PS Now that the code is correct the searches process far more quickly than I'd expected. Both our production (4.51) and development (2023) servers are high end, but the Verity searches on 4.51 are starting to stretch out & both machines are crunching about the same amount of data.
I was concerned about the necessary move to Solr. Primiarily because of all the necessary code changes. But I'd also seen a number of threads about slow performance.
Looks like I won't have to worry about the size of this collection for awhile. It flat blazes through the searches.
Copy link to clipboard
Copied
A suggestion:
<!--- Use \ to escape ".". The regular-expression match is from left to right, so place docx before doc --->
<cfset resultingString = REReplaceNoCase(theURL, "/|\.docx|\.doc|\.txt|\.pdf", "","all")>