|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- function get_class(name) {
- var clazz;
- try {
-
- clazz = eval("Java.type(name).class");
- } catch(e) {
-
- clazz = eval("Packages."+name);
- }
-
- return clazz;
- }
-
- function processAdd(cmd) {
-
- doc = cmd.solrDoc;
- var id = doc.getFieldValue("id");
- logger.info("update-script#processAdd: id=" + id);
-
-
-
-
-
- var ct = doc.getFieldValue("content_type");
- if (ct) {
-
- var semicolon_index = ct.indexOf(';');
- if (semicolon_index != -1) {
- ct = ct.substring(0,semicolon_index);
- }
-
- var ct_type = ct.substring(0,ct.indexOf('/'));
- var ct_subtype = ct.substring(ct.indexOf('/')+1);
-
- var doc_type;
- switch(true) {
- case /^application\/rtf/.test(ct) || /wordprocessing/.test(ct):
- doc_type = "doc";
- break;
-
- case /html/.test(ct):
- doc_type = "html";
- break;
-
- case /^image\/.*/.test(ct):
- doc_type = "image";
- break;
-
- case /presentation|powerpoint/.test(ct):
- doc_type = "presentation";
- break;
-
- case /spreadsheet|excel/.test(ct):
- doc_type = "spreadsheet";
- break;
-
- case /^application\/pdf/.test(ct):
- doc_type = "pdf";
- break;
-
- case /^text\/plain/.test(ct):
- doc_type = "text"
- break;
-
- default:
- break;
- }
-
-
- if(doc_type) { doc.setField("doc_type", doc_type); }
- doc.setField("content_type_type_s", ct_type);
- doc.setField("content_type_subtype_s", ct_subtype);
- }
-
- var content = doc.getFieldValue("content");
- if (!content) {
- return;
- }
-
- var analyzer =
- req.getCore().getLatestSchema()
- .getFieldTypeByName("text_email_url")
- .getIndexAnalyzer();
-
- var token_stream =
- analyzer.tokenStream("content", content);
- var term_att = token_stream.getAttribute(get_class("org.apache.lucene.analysis.tokenattributes.CharTermAttribute"));
- var type_att = token_stream.getAttribute(get_class("org.apache.lucene.analysis.tokenattributes.TypeAttribute"));
- token_stream.reset();
- while (token_stream.incrementToken()) {
- doc.addField(type_att.type().replace(/\<|\>/g,'').toLowerCase()+"_ss", term_att.toString());
- }
- token_stream.end();
- token_stream.close();
- }
-
- function processDelete(cmd) {
-
- }
-
- function processMergeIndexes(cmd) {
-
- }
-
- function processCommit(cmd) {
-
- }
-
- function processRollback(cmd) {
-
- }
-
- function finish() {
-
- }
|