我决定添加一个字段(cancerTerms)并在那里添加术语。但我不是在 Solr 之外这样做的。我正在使用分析链并将其传递给 ScriptUpdateProcessor。这里我可以取分析链的结果
并将结果存储到文档中(如 strField)。然后我在这个领域(cancerTerms)。这实际上给了我正确的结果,它没有给我关于 not 和不一定或任何其他类似问题的问题。另外我没有存储分析链字段(我以前是)。存储它是没有意义的,因为它是一个复制字段(显然复制字段只复制源文本然后将其通过管道传输到分析器,并且不能被链接)。我只存储链的结果(这对分面很有用)。
这是我在做什么的简化视图:
Content [被复制到] -> ColoCancerField(分析链 [未存储,
并将生成标记化字符串]) ->传递给更新脚本(已处理
每个标记作为字符串)[添加到] -> CancerTerms (strField)
id: 2040ee23-c5dc-459c-969f-2ebf6c728184
标题: 鼻息肉伴哮喘患者血液和黏膜嗜酸性粒细胞的免疫分布调节。
内容: 背景:慢性鼻窦炎伴鼻息肉(CRSwNP)常与哮喘相关。粘膜嗜酸性粒细胞 (EO)
已发现浸润与哮喘和疾病相关
严重性,但不一定在每个患者身上。其他多因素
需要免疫过程来确定疾病的内型和
对治疗的反应。目的:评估 EO 免疫调节
根据炎症蛋白的迁移和存活
CRSwNP 的概况和哮喘状态。方法:九十三
包括患有 CRSwNP 的患者(47 名哮喘患者)。每个病人都是
根据症状严重程度和息肉大小进行临床分期。鼻腔
收集分泌物以建立细胞因子谱。 EO
从血液样本和鼻息肉中纯化以描绘
通过流式细胞术检测特异性免疫表型并确定体外 EO
与哮喘状态相关的生存率。结果:CRSwNP 在
哮喘患者的特点是嗜酸性粒细胞增多和高
鼻分泌物中的白细胞介素 (IL)-5 水平。虽然 EO
在黏膜迁移后表现出激活曲线,有
IL-5受体的相对下调-? (IL-5R?)在鼻 EO 上
哮喘患者。含有 IL-5 和 IL-9 的 EO 培养物显示出
IL-5R对哮喘患者的抗凋亡作用?
调制。结论:黏膜嗜酸性粒细胞增多似乎是由 EO 引起的
通过调节黏附受体进行鼻诱捕。在患者中
对于哮喘,抗凋亡药物增强了 EO 的参与
T辅助细胞2型细胞因子对IL-5R的协同作用?
表达。这项研究首次表明IL-9参与
在 CRSwNP 的 EO 稳态中,可以解释
部分哮喘和鼻息肉患者的抗IL-5治疗。
细胞因子术语: t 细胞替代因子 ii 型干扰素 7 趋化因子白细胞介素 17 前体白细胞
介体白介素细胞替代因子 细胞替代因子9
蛋白质干扰素α-5细胞因子9蛋白
癌症术语:但不一定
版本: 1522116540216901632
得分: 1.0
这里是一些代码(请原谅混乱。我已经包含了 Solr 版本 5 的更改):
更新脚本
/***************************UpdateScript*********************************/
function getAnalyzerResult(analyzer, fieldName, fieldValue) {
var result = [];
var token_stream = analyzer.tokenStream(fieldName, new java.io.StringReader(fieldValue));//null value?
var term_att = token_stream.getAttribute(Packages.org.apache.lucene.analysis.tokenattributes.CharTermAttribute.class);
token_stream.reset();
while (token_stream.incrementToken()) {
result.push(term_att.toString());
}
token_stream.end();
token_stream.close();
return result;
}
function processAdd(cmd) {
doc = cmd.solrDoc; // org.apache.solr.common.SolrInputDocument
id = doc.getFieldValue("id");
logger.warn("update-script#processAdd: id=" + id);
var content = doc.getFieldValue("content"); // Comes from /update/extract
//facetList contains the actual facet terms
//facetAnalyzerName contains the Analyzer name for the term vector list names. (i.e the field type)
var facetList = ["cytokineTerms", "cancerTerms"];
var facetAnalyzerName = ["key_phrases", "ColonCancer"];
/*
Loop through all of the facets, and get the analyzer and the name for the field
Then add the terms to the document
*/
for(var i = 0; i < facetList.length; i++){
var analyzer = req.getCore().getLatestSchema().getFieldTypeByName(facetAnalyzerName[i]).getIndexAnalyzer();
var terms = getAnalyzerResult(analyzer, null, content);
for(var index = 0; index < terms.length; index++){
doc.addField(facetList[i], terms[index]);
}
}
}
// The functions below must be defined, but there's rarely a need to implement
// anything in these.
function processDelete(cmd) {
// no-op
}
function processMergeIndexes(cmd) {
// no-op
}
function processCommit(cmd) {
// no-op
}
function processRollback(cmd) {
// no-op
}
function finish() {
// no-op
}
/***************************UpdateScript*********************************/
updateRequestProcessorChain
/****************updateRequestProcessorChain ***********************/
<updateRequestProcessorChain name="script" default="true">
<processor class="solr.StatelessScriptUpdateProcessorFactory">
<str name="script">update-script.js</str>
<lst name="params">
<str name="config_param">example config parameter</str>
</lst>
</processor>
<processor class="solr.LogUpdateProcessorFactory"/>
<processor class="solr.RunUpdateProcessorFactory" />
</updateRequestProcessorChain>
/****************updateRequestProcessorChain ***********************/
使用帖子上传
java -Durl=http://localhost:8983/solr/Cytokine/update -Dauto -Dparams=update.chain=script -jar bin/post.jar C:/Users/Kevin/Downloads/pubmed_result.json
来源:
- http://lucidworks.com/blog/2013/06/27/poor-mans-entity-extraction-with-solr/
- https://www.youtube.com/watch?v=AXSK2RvVJsk
-
https://wiki.apache.org/solr/ScriptUpdateProcessor
4.https://lucene.apache.org/solr/5_0_0/changes/Changes.html#v5.0.0.upgrading_from_solr_4.x
- https://gist.github.com/erikhatcher/50e653c1c09abb68e068
存档:
https://mail-archives.apache.org/mod_mbox/lucene-solr-user/201512.mbox/%3CCAH57+p4FK=Ta84dEpUR4p0xWQ2YWkOWPpj566ZZzhdjW9F_ZJg@mail.gmail.com%3E