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