For the past week or so I've been working on the updated full-text searching chapter of the ColdFusion Web Application Construction Kit. We are totally removing all mention of Verity (outside of that fact that it used to be the only engine supported) and focusing entirely on Solr. While working through the chapter I ran across a couple of "gotchas" that I thought I'd share for anyone considering migrating to ColdFusion 9 and taking the initiative to also update to Solr. This is by no means a complete list - it's just what I encountered. Comments, corrections, and additions are welcome.
Edited: Let me stress - Solr and Verity are very different products. The point of this article is to focus on the differences at the ColdFusion level only.
- Speed: Ok so this isn't something to worry about per se, but it bears repeating. Solr in CF9 is four times faster than Verity. Sweet.
- NO LIMIT! Ditto the above statement about not being something to worry about, but just in case you didn't like the index limits in Verity, you will be happy to know that there are no limits to the size of your Solr based collections. Thank you Henry Ho for reminding me of this.
- When creating a Solr collection, you do not need to specify a language. But you can specify it for cfindex and cfsearch.
- When creating a Solr collection, categories are automatically supported. In the admin UI it is disabled even. It just plain works out of the box.
- In Verity, a search for an uppercase or lowercase term resulted in a case insensitive search. If you supplied a mixcase term though the search was case sensitive. Solr is case insensitive no matter what the case.
- Edited October 31, 2009. Solr does support AND and OR. The docs, however, seem to imply it only supports + and - (for not). This is not the case. Both formats are supported.
Solr doesn't support AND or OR, instead, you have to use the + operator to require words. So to require A and B, you would use: +A +B. To support A or B you would use: A B. I will say that one example in the docs (url linked below) shows OR. That may be a typo. - To support NOT (ie, include something but preclude any result that has something else) you use the - operator. Example: A -B.
- Solr supports wildcards like Verity (* and ?) but it cannot be used as the first character in a search. You want to consider writing a UDF to handle "fixing" search terms for users in case they make a mistake like this. CFLib> has one for Verity already.
- For more details on operators and search examples, see this documentation page: Solr search examples
- Solr does not support previousCriteria. This is a feature where you can search within the result set of another search. While it may not be the same, you could mimic this with query of query.
- Verity scores range from 0 to 1, with 0 meaning it sucks and 1 meaning it rules. In Solr it's a bit different. There is no (as far as I can tell) upper range. The higher the number though the better the result. Basically you probably don't want to bother displaying the score.
- With Verity, you can ask for suggestions. This was used along with the status attribute. It would return a structure of which one key was named suggestedquery. Solr still returns this, but the value is just the corrected spelling of one search term. So if you searched for nmber one, it may tell you "number" as the correct spelling. But - if you want to provide a better search term - use collatedResult. This key would have both the fixed spelling and the rest of the query. So it would show something like "number one" as the value.
- With Verity, to use a field during a search, you would do cf_custom1
something. In Solr, all these fields drop the cf_ in front. - The cfcollection docs state that if you leave engine off when using the list operation, you will get all collections. Under OSX at least this is not the case. You must specify engine="solr" to get Solr collections.
That's all I have for now. I plan on updating my Verity CF Admin to work with Solr. This tool allows you to perform ad-hoc searches against collections via the CF Admin. I'm then going to follow up with an index of the ColdFusion HTML documentation and compare some searches in Verity via Solr.


Comment 1 written by Sean Coyne on 30 October 2009, at 12:55 PM
Comment 2 written by Dan G. Switzer, II on 30 October 2009, at 1:48 PM
Comment 3 written by kevin penny on 30 October 2009, at 3:24 PM
Personally I'd use solr stand alone and tweak the configs - but another thing you can do is find the ip/port solr is running on and execute your search through the browser and append ?debugQuery=true to see exactly what your search string is resulting to, as it's difficult at times to determine output response w/o having this debug information (can be found at something like 127.0.0.1:8983/solr/select?q=Jim Jones&debugQuery=true type of a url)
I did a cfug topic on this stuff at colderfusion.com - Long live Solr!
Comment 4 written by kevin penny on 30 October 2009, at 3:30 PM
I'm not a fan of the implementation, as they just tried to be 'verity-like' with the results.
http://wiki.apache.org/solr/CommonQueryParameters?...|%28filter%29#fq
I'd do outside CF's implementation and go directly to solr and parse the xml files returned.
Comment 5 written by Raymond Camden on 30 October 2009, at 3:32 PM
@Kevin: Nice to know. I'm not sure I'd agree with you about 'going' native. It's nice that you can for sure, but for most users, I don't think it will be an option they are comfortable with, or would need per se.
Comment 6 written by kevin penny on 30 October 2009, at 3:52 PM
http://lucene.apache.org/java/2_4_0/queryparsersyn...
Here's a raw search string that can be executed once a solr 'collection' in cf9 has been created called 'core0'
http://127.0.0.1:8983/solr/core0/select/?q=Belkin%...
Where I'm searching for both 'Belkin' AND 'ipod' together in the same document - from the debugQuery output it states:
+contents:belkin +contents:ipod which essentially converts the AND to plus signs. This is what solr is doing under the hood.
Comment 7 written by Raymond Camden on 30 October 2009, at 3:55 PM
Comment 8 written by kevin penny on 30 October 2009, at 4:03 PM
Comment 9 written by Dan G. Switzer, II on 30 October 2009, at 4:06 PM
Comment 10 written by Raymond Camden on 30 October 2009, at 4:08 PM
Comment 11 written by kevin penny on 30 October 2009, at 4:11 PM
Comment 12 written by Rick Mason on 30 October 2009, at 5:12 PM
Solr has a lot of features that aren't exposed by CF. But there is a javascript library that does expose many more called Ajax Solr:
http://asserttrue.blogspot.com/2009/10/introducing...
While I haven't used the Ajax Solr yet - javascript is a wee bit easier for me to grok than java.
Comment 13 written by Raymond Camden on 30 October 2009, at 5:14 PM
Comment 14 written by Raymond Camden on 31 October 2009, at 8:49 AM
Comment 15 written by John Lang on 2 November 2009, at 7:20 AM
In any case, Solr sounds promising. I work for the government so we'll probably have it when CF 10 is out. We just recently (3 months or so) upgraded to CF 8.
Thanks for the post comparing the 2 Ray!
Comment 16 written by Ryan Stille on 18 January 2010, at 8:51 AM
I was getting ready to migrate from Verity to Solr but this really makes me rethink that decision.
Comment 17 written by Raymond Camden on 18 January 2010, at 8:53 AM
Comment 18 written by Ryan Stille on 18 January 2010, at 9:00 AM
Comment 19 written by Raymond Camden on 18 January 2010, at 9:20 AM
Comment 20 written by Steven Erat on 26 January 2010, at 1:19 PM
If you have multiple CF instances installed on the same server then they can all connect to a single K2 server. But if you have a remotely distributed ColdFusion cluster where clustered instances exist on different servers, then they cannot all connect to the same K2 server.
This is a serious problem limiting scalability. In that scenario, all instances on a particular server host must connect to their own K2 server, and manage its collections there. A CF instance from each server must manage creating, optimizing, and indexing collections, and since it must also be performed by CF instances on other servers this becomes an redundant task that is prone to headaches if the different K2 servers get out of sync.
Sooooo, my question is, if I install CF9 with Solr and decide to put Solr on its own server, can I have a CF9 cluster across multiple servers where all instances can connect to a single Solr server?
I suspect that this will be possible. If so, then this is a major advantage because it reduces maintenance efforts, eliminates synchronization problems, and most importantly lets you better scale ColdFusion applications.
I could install and try it out, but I thought I'd share my thoughts on this potential advantage here.
Comment 21 written by Shalin Shekhar Mangar on 26 January 2010, at 3:04 PM
I've absolutely no idea about what the Solr schema and queries look like so I cannot comment on the relevancy issues.
Comment 22 written by larry on 18 February 2010, at 3:49 AM
Comment 23 written by Fabio on 4 August 2010, at 4:56 AM
Comment 24 written by Raymond Camden on 4 August 2010, at 7:03 AM
[Add Comment] [Subscribe to Comments]