Hey, folks. I've been a long-time Lucene user (running a hilariously-old 1.9.1 version forever), but I'm only just now getting into using Solr.
My particular use-case is storing information about web-application users so they can be found more quickly than our current RDBMS-based search (SELECT ... FROM user WHERE username LIKE '%foo%' OR email_address LIKE '%foo%' OR last_name LIKE '%foo%'...). I've set up my Solr (very basic... just untar, bin/solr start), created a core/collection (I'm running single-server for now, no cloudy zookeeper stuff ATM), customized my schema (using the Schema API, since hand-editing is discouraged) and loaded my data. I can search just fine through the Solr dashboard. I've also user solr-solrj to perform searches from within my application, replacing the previous JDBC-based search with the Solr-based one. All is well. Now I'm trying to figure out the best way to update users in the index when their information (e.g. first/last names) change. I have used solr-solrj quite simply like this: SolrInputDocument doc = new SolrInputDocument(); doc.addField("id", user.getId()); doc.addField("username", user.getUsername()); doc.addField("first_name", user.getFirstName()); doc.addField("last_name", user.getLastName()); ... solrClient.add("users", doc); solrClient.commit(); I'm having a problem, though, and I'd like to know what the "right" solution is. The problem is that I'm updating the index after my SQL UPDATE(s) have run, but before my SQL COMMIT occurs. I have had a problem where the SQL fails and rolls-back, but the solrClient is not rolled-back. I'm a little wary of rolling-back Solr because, as I understand it, the client itself doesn't carry any transactional information. That is, it should be a shared-resource (within the web application) and indeed, other clients could be connecting from other places (like other app servers running the same application). Performing either commit() or rollback() on the Solr client will commit/rollback *all* writes since the last commit, right? That means that there is no meaningful way that I can say to Solr "oops, I actually need you to NOT add that document I just told you about". Instead, I have to either commit the document I don't want (and, I dunno, delete it later or whatever) or risk rolling-back other writes that other clients have performed. Do I have that right? So... what's the best way to do this kind of thing? Can I ask Solr to add-and-commit at the same time? If so, how? Is there a meaningful "rollback this one addition" that I can perform? If so, how? Thanks for a great product, -chris
signature.asc
Description: OpenPGP digital signature