This week I worked with a user who was having an interesting issue with Solr-based searches under ColdFusion. He was trying to make use of "boosting", which is a way of saying that a match found in one field should be considered more important than another. So for example, imagine you have a collection of articles. The user searches for N and you want to ensure that if the title includes N it is rated higher. Normally Solr is going to use it's own judgement. It may say, for example, that if N occurs a crap load in the body then it should be rated higher than an article with N in the title. While that logic makes sense, Solr does allow you to weigh different fields higher if you want. Normally the syntax should be something like this:
#search# OR title:#search#^10
However, in testing with the user, this didn't seem to work consistently. And then I noticed something odd. For our testing, we were using "ColdFusion" as a search string. While I tested I once did "coldfusion" and noticed that a record that should not have been returned wasn't. I hit up my Solr expert, Shannon Hicks for help. Together we found that the Solr configuration ColdFusion creates sets title as a case sensitive field. That's important to know in general, but certainly impacted our tests here.
So the fix? I simply had the user employ one of the custom fields as a copy of the title field. Once done we could then do:
#search# OR custom1:#search#^10
And it worked immediately. I hope this is helpful!
Archived Comments
When you create a Solr collection in ColdFusion it creates the title field using the "text_ws" type. What you can do if you want the title field to act more or less like it did under Verity is to change that "text_ws" (a case-sensitive type) to "text" (a case-insensitive type) in the schema.xml file (under Windows this can be found under C:\ColdFusion9\collections\<collection_name>\conf\schema.xml, assuming it was created in the default location) and restart the Solr service. That might be more than most people are prepared to do. The only issue with using the custom1 field or another custom field is that it keeps you from using that field for some other piece of data. Hope this helps.
Just as a followup, I blogged on this issue here:
http://www.thefaberfamily.o...
Truthfully, I think it is a bug in the way CF creates the Solr collection (why should "title" all of a sudden be case-sensitive?) but it is easy enough to fix schema.xml, restart the Solr service, and index the collection.