我对Solr很新 . 在提出这个问题之前,我已经通过了这个帖子(Need help indexing XML files into Solr using DataImportHandler) . 但它没有帮助,因为我对Apache Solr很新 . 我希望索引一个xml文件并搜索其内容 . 它的结构类似于这样的东西
<entry id="REACT_142474" acc="REACT_142474.5">
<name>((1,6)-alpha-glucosyl)poly((1,4)-alpha-glucosyl)glycogenin => poly{(1,4)-alpha- glucosyl} glycogenin + alpha-D-glucose</name>
<description>This event has been computationally inferred from an event that has been demonstrated in another species.The inference is based on the homology mapping in Ensembl Compara. Briefly, reactions for which all involved PhysicalEntities (in input, output and catalyst) have a mapped orthologue/paralogue (for complexes at least 75% of components must have a mapping) are inferred to the other species. High level events are also inferred for these events to allow for easier navigation.More details and caveats of the event inference in Reactome. For details on the Ensembl Compara system see also: Gene orthology/paralogy prediction method.</description>
<dates>
<date type="creation" value="06-JUN-2013"/>
<date type="last_modification" value="06-JUN-2013"/>
</dates>
<cross_references>
<ref dbname="ChEBI" dbkey="17925"/>
<ref dbname="UniProt" dbkey="Q06625"/>
<ref dbname="ChEBI" dbkey="18291"/>
<ref dbname="UniProt" dbkey="P47011"/>
<ref dbname="UniProt" dbkey="P36143"/>
<ref dbname="GO" dbkey="GO:0004135"/>
<ref dbname="taxonomy" dbkey="4932"/>
</cross_references>
<additional_fields>
<field name="organism">Saccharomyces cerevisiae</field>
</additional_fields>
</entry>
是否必须使用DIH将此数据导入Solr?有没有更简单的方法来完成任务?可以通过SolrJ完成,因为我也可以通过控制台输出结果 . 除了官方文档之外,如果有人可以向我指出一些有用的示例或资源,那将会非常有用 .
2 回答
以下是使用Solrj解析然后索引XML文件的groovy示例:
parse Solr xml files to SolrInputDocument
Need help indexing XML files into Solr using DataImportHandler
我使用你发布的链接在我自己的数据上使用XPathEntityProcessor . 我当时是新手,但并不困难 .
如果您想使用SolrJ,请查看此link以获取示例 . 我假设您可以使用您想要的任何XML解析器解析XML,然后使用SolrJ将新文档添加到索引中 .