update-script.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. This is a basic skeleton JavaScript update processor.
  3. In order for this to be executed, it must be properly wired into solrconfig.xml; by default it is commented out in
  4. the example solrconfig.xml and must be uncommented to be enabled.
  5. See http://wiki.apache.org/solr/ScriptUpdateProcessor for more details.
  6. */
  7. function processAdd(cmd) {
  8. doc = cmd.solrDoc; // org.apache.solr.common.SolrInputDocument
  9. id = doc.getFieldValue("id");
  10. logger.info("update-script#processAdd: id=" + id);
  11. // Set a field value:
  12. // doc.setField("foo_s", "whatever");
  13. // Get a configuration parameter:
  14. // config_param = params.get('config_param'); // "params" only exists if processor configured with <lst name="params">
  15. // Get a request parameter:
  16. // some_param = req.getParams().get("some_param")
  17. // Add a field of field names that match a pattern:
  18. // - Potentially useful to determine the fields/attributes represented in a result set, via faceting on field_name_ss
  19. // field_names = doc.getFieldNames().toArray();
  20. // for(i=0; i < field_names.length; i++) {
  21. // field_name = field_names[i];
  22. // if (/attr_.*/.test(field_name)) { doc.addField("attribute_ss", field_names[i]); }
  23. // }
  24. }
  25. function processDelete(cmd) {
  26. // no-op
  27. }
  28. function processMergeIndexes(cmd) {
  29. // no-op
  30. }
  31. function processCommit(cmd) {
  32. // no-op
  33. }
  34. function processRollback(cmd) {
  35. // no-op
  36. }
  37. function finish() {
  38. // no-op
  39. }