alok
alok

Reputation: 2756

How to do Solr search integration with PHP?

I have solr on my local machine and its working fine when I am hitting this url:

http://localhost:8983/solr/

but I am new in solr search and I don't know how to configure PHP and MySQL with Solr.

I am using windows8 and solr5.1.0. If any one have command in solr+php+mysql then please suggest.

Upvotes: 2

Views: 826

Answers (1)

SaidbakR
SaidbakR

Reputation: 13534

Simply and mainly you will need two native PHP functions:

Here are a simple custom function in which you have to supply it with full URL query to your Solr such as http://localhost:8080/solr/wak/select?q=SearchPool%3Aالصلاة&wt=json&indent=true of course it changed depending on your schema and the requirements of query.

function readQuery($q){     
        $data = file_get_contents($q);
        return json_decode($data);
    }

The readQuery function returns a JSON object, notice wt=json in the URL, with the query results. For debugging and knowing how to access the objects properties you may use var_dump.

Upvotes: 4

Related Questions