开发者

php arrays into solr index

开发者 https://www.devze.com 2023-03-18 04:58 出处:网络
I\'ve been using mysql just to practice getting data stored. What I do is get the textnodes of an html document, its y coordinate relative to the document, and the url. I was wondering how I could do

I've been using mysql just to practice getting data stored. What I do is get the textnodes of an html document, its y coordinate relative to the document, and the url. I was wondering how I could do this straight into solr (since it uses 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. XML Format of solr is described in their wiki(see here).

You add then your fields to the document with some names(as configured by your schema.xml). And post it to the solr interface.

See e.g. the example using curl. PHP has also a curl library. So you can implement anything there with ease.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号