简体   繁体   English

php arrays 成 solr 索引

[英]php arrays into solr index

I've been using mysql just to practice getting data stored.我一直在使用 mysql 只是为了练习存储数据。 What I do is get the textnodes of an html document, its y coordinate relative to the document, and the url.我所做的是获取 html 文档的文本节点、其相对于文档的 y 坐标以及 url。 I was wondering how I could do this straight into solr (since it uses xml).我想知道如何直接在 solr 中执行此操作(因为它使用 xml)。 Some general guidance would be great as well.一些一般性的指导也很好。

for($i=0; $i<count($textnode); $i++) {

$textnode[$i] = stripslashes($textnode[$i]);
$textnode[$i] = mysql_real_escape_string($textnode[$i], $con);



 mysql_query("INSERT INTO paragraphs (paragraphs, ytext, url)
 VALUES ('$textnode[$i]','$ytext[$i]', '$url')");



}

You take an available xml document library(there are more than one the most simple would be probably SimpleXML ) in your php script.您在 php 脚本中使用了一个可用的 xml 文档库(有不止一个最简单的可能是SimpleXML )。 XML Format of solr is described in their wiki( see here ). XML solr 的格式在他们的 wiki 中有描述(见这里)。

You add then your fields to the document with some names(as configured by your schema.xml).然后,您将您的字段添加到具有一些名称的文档中(由您的 schema.xml 配置)。 And post it to the solr interface.并贴到solr接口。

See eg the example using curl.参见例如使用 curl 的示例。 PHP has also a curl library. PHP 还有一个 curl 库。 So you can implement anything there with ease.所以你可以轻松地在那里实现任何东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM