SOLR 9.0我正在尝试访问req变量,如下所述:
https://solr.apache.org/guide/solr/latest/configuration-guide/script-update-processor.html#script-execution-context
然而,在我的回应中,我得到这个错误:
Unable to invoke function processAdd in script: test-script.js: TypeError: Can not extend/implement [class org.apache.solr.request.SolrQueryRequestBase] because of java.security.
它指出错误位于第15行,
some_param = req.getParams().get("commit")
这就是文档中的示例。
这似乎是SOLR和nashborn JavaScript处理器之间的不兼容。
在此处完成脚本:
`/*
This is a basic skeleton JavaScript update processor.
In order for this to be executed, it must be properly wired into solrconfig.xml; by default it is commented out in
the example solrconfig.xml and must be uncommented to be enabled.
See http://wiki.apache.org/solr/ScriptUpdateProcessor for more details.
*/
function processAdd(cmd) {
doc = cmd.solrDoc; // org.apache.solr.common.SolrInputDocument
childDocsPresent = doc.hasChildDocuments();
some_param = req.getParams().get("commit")
request = req.getJSON();
// request.forEach((key, value) => {
// logger.warn(key, value)
// });
logger.warn("The value of child docs present is " + childDocsPresent);
`// Set a field value:
// doc.setField("foo_s", "whatever");
// Get a configuration parameter:
// config_param = params.get('config_param'); // "params" only exists if processor configured with <lst name="params">
// Get a request parameter:
// some_param = req.getParams().get("some_param")
// Add a field of field names that match a pattern:
// - Potentially useful to determine the fields/attributes represented in a result set, via faceting on field_name_ss
// field_names = doc.getFieldNames().toArray();
// for(i=0; i < field_names.length; i++) {
// field_name = field_names[i];
// if (/attr_.*/.test(field_name)) { doc.addField("attribute_ss", field_names[i]); }
// }
}
function processDelete(cmd) {
// no-op
}
function processMergeIndexes(cmd) {
// no-op
}
function processCommit(cmd) {
// no-op
}
function processRollback(cmd) {
// no-op
}
function finish() {
// no-op
}
我尝试了发布的脚本,但请求运行时没有引发错误。
1条答案
按热度按时间kg7wmglp1#
此错误是SOLR 9.0中的新安全设置造成的。通过编辑solr.in.sh并添加以下行,已将其删除:SOLR_安全管理器_启用=假