I'm working with a database that stores links to various pieces of government regulation. Each regulation has a discipline, subdiscipline, regulation type, and responsible office. Each one also has a list of assigned keywords.
Previously, we were just using an HTML form to do a <cfquery> to search these items. At one point, someone tied our Google appliance into the keyword search to improve results, but now we're dumping the appliance due to cost issues. I've been asked to come up with a replacement for the appliance, so my first thought was Solr.
I've created a collection, then used cfindex to index it. If I use cfsearch to pull keyword results, it works quite well. Here's my cfindex tag:
My problem is that I'm being asked to combine the keyword (Solr) search with the HTML form (select drop-downs for category, subcategory, regulation type, etc) and I'm having some trouble making that work. If someone enters a keyword, no problem. I can use a QoQ to parse the query results. But it's not so easy if the keyword is left blank because then the cfsearch takes AGES to run. I wish I could force a keyword, but going by stats, at least half of everyone omits them, so I don't want to fiddle with how people use the form.
Has anyone here had any experience using Solr to search database content like this?
Success. I basically just indexed all the things I wanted to search on and fed them into the body attribute, then used custom 1-4 for the ID numbers, so I can further parse the results.
I just wish I had more than 4 custom placeholders, because I'd like to pass two more items through. Anyway, at least this takes care of my blank keyword problem.
Aha! Turns out I can have all the custom fields I want, using name_datatype
So in the <cfindex> tag I can have:
The sky's the limit!
Slight bug with the custom fields. The documentation states that the syntax is fieldname_datatype (i.e. field1_s for string, field1_i for integer, etc). But I get a datatype mismatch error (There is an invalid attributname-attributevalue combination) whenever I use anything but _s, even with numeric fields.
Looks like it's also been reported here: Bug#3935959 - Solr on ColdFusion 10 Does not Support More than 4 Custom Fields
Fortunately, the _s works, so I can use that as a workaround.