Adobe MAX 2011 CF Unconference Presenation: Advanced Solr - Going Beyond the Basics of cfsearch

For those who attended my session on Monday and wanted to download the sample code, you can download it here (2.4MB zip file).

The code is ready to go (requires CF9 or better if you want to run it out of the box without having to download Solr on your own). Make sure to glance at the readme.txt file before you start. It also has some troubleshooting tips in case you can't get the code running right away.

I've separated each of the samples into include files (demo1.cfm, demo2.cfm, etc) to make it easy to follow. And I've also included a ton of really helpful notes at the top of each demo file that walks you through exactly what I discussed in my session.

I gave this same session at CF.Objective() 2011 earlier this year. So for those who already downloaded that code there isn't anything new for you (sorry). But I did update the live session with more helpful specifics based on feedback from CF.Objective().

Download and enjoy!

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Merritt's Gravatar How much work would it take to make you examples work with files (.doc, .pdf) instead of database records?
#1 by Merritt | 10/6/11 8:14 PM
Jeff Coughlin's Gravatar It would take a little more work to get it setup (not a big deal... just something I hadn't made demo code for).

But my advice is to really start looking at Solr 3.x which has great interaction with Apache Tika (

Before you start asking yourself how to get all that working, take a look at cfsolrlib2 (my code examples for this preso use cfsolrlib1) - which works with Solr 3.x and Tika. Not only does it have sample code for both (it also shows an example on how to search a PDF), but it includes working copies of Solr 3.2 and Tika. For production use, make sure to update Solr to the latest version (as I write this, the current stable release is 3.4).

One thing to keep in mind is that the library changed things a bit from the first version. Like when doing a search, the query (q variable) is a required field. And when adding data, you send it in as a CF array instead of xml. Very minor differences though, otherwise mostly the same (but better).

Good luck.
#2 by Jeff Coughlin | 10/7/11 11:32 AM
Rhys Jones's Gravatar Jeff, thanks for the great example. In looking over the addFile method, there is an optional argument called literalData that is a structure that, if I'm reading this correctly, would map literal data to the contents of additional fields in the schema if you had them. So for example, if you had a product brochure PDF and the product's ID wasn't explicit in the content of the PDF, you could add a field to your schema called productID and using this literalData structure, add the product's ID so its searchable? Is that correct?
#3 by Rhys Jones | 3/9/12 1:35 PM
snake's Gravatar is it possible to upgrade the SOLR that ships with CF to the latest version ?
It's version 4 now and CF9 only has 1.4
#4 by snake | 1/17/13 8:27 AM
Jeff Coughlin's Gravatar Snake, Sorry for the late response. The answer unfortunately is no. Well, not easily. Adobe makes a lot of custom changes to the schema.xml and other settings to accommodate for ColdFusion integration.

Personally I use Solr by itself on all my projects. It's integrated features got better in CF10, but it's still very limited for the needs of my clients and frankly Solr is so easy to use by itself anyway.
#5 by Jeff Coughlin | 4/26/14 3:20 PM
gordon's Gravatar So my CF APP server is Win 64bit and CF10 SOLR (3.?) is toast. "Solr is so easy to use" - what installation/configuration/3rd party connection documentation do you recommend? Looking for guidance on gotchas, snippets to use in CF to connect to free-standing SOLR. I'm desperate :/
#6 by gordon | 6/27/14 11:55 AM
Jeff Coughlin's Gravatar @Gordon, take a look at CFSolrLib2 (written for Solr 3.x though, not more recent versions). And for file indexing, take a look at Tika

Personally for the last couple years I've mostly been using Solr 3.5 with FarCry (an open source CMS). If you decide to look into the CMS, there is a pretty decent Solr plugin that you can find here Even if you're not interested in the CMS, there is a lot of useful code you can pull from the plugin (which in essence is taking advantage of CFSolrLib2 and also talks to Tika for file indexing).

Good luck.
#7 by Jeff Coughlin | 10/7/14 8:46 PM

BlogCFC by Raymond Camden | RSS | Contact Blog Owner