0

我解析了一个 xml 文件并从文件中提取“标题”、“ID”和“文本”并将它们存储为对象。我有一组包含来自 xml 文件的信息的对象。现在我想将这些对象索引到 solr 中,以便我可以搜索相关文件。有没有办法我可以做到这一点?需要帮助。

4

1 回答 1

1

Where are those objects of yours stored?

You can use API (java, python, ruby, js, scala, perl, PHP and even .NET) to send data to Solr directly from your source code.

Regardless of programming language, you can use standard HTTP POST to push XML, CSV, or JSON documents to Solr.
See here for all update request handlers (who handles your request on Solr server) wiki pages.
And here to check out (javaDoc) which classes implement SolrRequestHandler.

If you have some kind of RESTfull service or standard web service that can return XML, you have the option to use DataImportHandler to read from that source. It is then used in combination with XPathEntityProcessor, which would avoid you having to parse your XMLs manually.

Whichever way you choose to go, first you need to prepare Solr schema.xml (add your Title, ID and Text fields) so Solr knows how to index your data.

And before all this I suggest you go through Solr quick start tutorial.

于 2012-04-06T08:24:17.790 回答