You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Faire Mii <fa...@gmail.com> on 2009/12/15 14:49:30 UTC

solr php client vs file_get_contents?

i am using php to access solr and i wonder one thing.

why should i use solr php client when i can use

$serializedResult = file_get_contents('http://localhost:8983/solr/ 
select?q=niklas&wt=phps');

to get the result in arrays and then print them out?

i dont really get the difference. is there any richer features with  
the php client?


regards

fayer

Re: solr php client vs file_get_contents?

Posted by Donovan Jimenez <dj...@conduit-it.com>.
In the end, the PHP client does a file_get_contents for doing a  
search the same way you'd do it "manually".  It's all PHP, so you can  
do anything it does yourself. It provides what any library of PHP  
classes should - convenience. I use the JSON response writer because  
it gets the most attention from the Solr community of all the non-XML  
writers, yet is still very quick to parse (you might want to do your  
own tests comparing the speed of unserializing a Solr phps response  
versus json_decode'ing the json version).

Happy Solr'ing,
- Donovan

On Dec 15, 2009, at 8:49 AM, Faire Mii wrote:

> i am using php to access solr and i wonder one thing.
>
> why should i use solr php client when i can use
>
> $serializedResult = file_get_contents('http://localhost:8983/solr/ 
> select?q=niklas&wt=phps');
>
> to get the result in arrays and then print them out?
>
> i dont really get the difference. is there any richer features with  
> the php client?
>
>
> regards
>
> fayer


Re: solr php client vs file_get_contents?

Posted by Israel Ekpo <is...@gmail.com>.
On Tue, Dec 15, 2009 at 8:49 AM, Faire Mii <fa...@gmail.com> wrote:

> i am using php to access solr and i wonder one thing.
>
> why should i use solr php client when i can use
>
> $serializedResult = file_get_contents('http://localhost:8983/solr/
> select?q=niklas&wt=phps');
>
> to get the result in arrays and then print them out?
>
> i dont really get the difference. is there any richer features with the php
> client?
>
>
> regards
>
> fayer



Hi Faire,

Have you actually used this library before? I think the library is pretty
well thought out.

>From a simple glance at the source code you can see that one can use it for
the following purposes:

1. Adding documents to the index (which you cannot just do with
file_get_contents alone). So that's one diff

2. Updating existing documents

3. Deleting existing documents.

4. Balancing requests across multiple backend servers

There are other operations with the Solr server that the library can also
perform.

Some example of what I am referring to is illustrated here

http://code.google.com/p/solr-php-client/wiki/FAQ

http://code.google.com/p/solr-php-client/wiki/ExampleUsage

IBM also has an interesting article illustrating how to add documents to the
Solr index and issue commit and optimize calls using this library.

http://www.ibm.com/developerworks/opensource/library/os-php-apachesolr/

The author of the library can probably give you more details on what the
library has to offer.

I think you should download the source code and spend some time looking at
all the features it has to offer.

In my opinion, it is not fair to compare a well thought out library like
that with a simple php function.
-- 
"Good Enough" is not good enough.
To give anything less than your best is to sacrifice the gift.
Quality First. Measure Twice. Cut Once.
http://www.israelekpo.com/