how to use solr with mysql and php?

2019-03-21 15:23发布

问题:

i read about how i could use solr to search in my threads but i dont quite understand how it works and i cant find any articles explaining this for a total beginner.

could someone explain briefly how solr works and how it communicate with mysql and php?

回答1:

First take a look at this tutorial.

With solr you will need to have an xml (or csv) document which will be pushed to solr (process is called updating; indexing is the process to make fields available for search). The format of xml is sth. like:

<add>
  <doc>
    <field name="id">9885A004</field>
    <field name="name">Canon PowerShot SD500</field>
    <field name="category">camera</field>
    <field name="features">3x optical zoom</field>
    <field name="features">aluminum case</field>
    <field name="weight">6.4</field>
    <field name="price">329.95</field>
  </doc>
</add>

Look here for more details.

But in your case you could use a crawler (appropriated if different or external sources) to get different document formats recognized. Try to understand if Nutch could help here.

E.g. take a look at this presentation for an explanation about solr, lucene and nutch.