Components for script-based search, index, and collection

This post is more than 2 years old.

Attached to this blog entry are new CFCs that will allow you to perform collection operations (cfcollection, cfindex, and cfsearch) view script based CFCs. From the attached zip, simply store the components in your cfinstall\customtags\com\adobe\coldfusion folder. (Make a backup of base.cfc first!!) The test files are just that - tests. They mainly work with a collection I had called 'test' so you should not expect them to work as is. They are mainly there to provide you with an example. Here are a few examples...


<cfscript> c = new com.adobe.coldfusion.collection();

collections = c.list(); writedump(var=collections,label="Collections, no engine");

clist = c.categoryList(collection="test"); writedump(var=clist,label="Category list for collection test");

//random name newname = "tempcollection_#replace(createUUID(), "-","_","all")#"; c.create(collection=newname,path=server.coldfusion.rootdir & "/collections");

writeoutput("<p>Made #newname#</p>");

collections = c.list(); writedump(var=collections,label="Collections");


collections = c.list(); writedump(var=collections,label="Collections after I deleted the new one");

c.optimize(collection="test"); writeoutput("Optimized test"); </cfscript>


<cfscript> //q is a query I made earlier, ditto for q2 idx = new com.adobe.coldfusion.index(); r = idx.refresh(collection="test",key="id",body="body",query=q,status=true); writeDump(var=r,label="refresh");

writeoutput("size of q2 - adding - #q2.recordCount#<br/>"); r = idx.update(collection="test",key="id",body="body",query=q2,status=true); writeDump(var=r,label="update");

r = idx.delete(collection="test",key=1,status=true); writeDump(var=r,label="delete");

r = idx.purge(collection="test",status=true); writeDump(var=r,label="purge"); </cfscript>


<cfscript> mysearch = new; res ="cfabort",collection="cfdocs",maxrows=5,status="true");

writedump(var=res); writeoutput("<hr/>Done"); </cfscript>

Download attached file.

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA

Archived Comments

Comment 1 by Adam Tuttle posted on 11/15/2011 at 10:26 AM

Ray, would you be ok including these in the project/org I just created?

Everything else in there is licensed under the MIT License, so I would hope you'd be ok licensing your stuff with that as well. MIT is nice because it allows Adobe (or anyone else) to include them in a commercial product... you know... like ColdFusion. ;)

If so, feel free to send a pull request!

Comment 2 by Raymond Camden posted on 11/15/2011 at 7:08 PM

I'm fine as long as 'written by Ray' is somewhere in there. I forget if I had that in there or not.

Comment 3 by Adam Tuttle posted on 11/15/2011 at 7:10 PM

Cool. I'll add them and be sure you're lavishly credited. ;)

Comment 4 by Adam Tuttle posted on 11/15/2011 at 7:12 PM

Oh yeah, you changed base.cfc... Have you tested to see if it breaks any of the other cfcs that use it? I assume you're using them regularly and already have it overwritten...

Comment 5 by Raymond Camden posted on 11/15/2011 at 7:13 PM

Nope, it should not. I'm pretty offended you implied my code may have bugs. (Ahem. ;)

Comment 6 by Adam Tuttle posted on 11/15/2011 at 7:21 PM

Looking at what your changes were, I feel safe including it. Thanks for the contribution, Ray!