How to add search with Solr


You may also like...

24 responses to “How to add search with Solr”

  1. HJ says:

    The article is great, but full of mistakes! Took me hours to find them. Check constants and see how they were used export.php.
    (for example it was defined DBPASS you used DB-PASSWORD)

  2. Utkarsh Agrawal says:

    Its been almost a day, but could not fix the error below. I get it when i finish the steps of “Indexing data”:

    Select returned 5 rows.

    Fatal error: Uncaught exception
    ‘Apache_Solr_HttpTransportException’ with message ”500′ Status:
    Internal Server Error’ in
    /opt/lampp/htdocs/xx/SolrPHPCient/Apache/Solr/Service.php:364
    Stack trace:
    #0 /opt/lampp/htdocs/xx/SolrPHPCient/Apache/Solr/Service.php(669):
    Apache_Solr_Service->_sendRawPost(‘http://localhos…’, ‘add(‘addDocuments(Array)
    #3 {main}
    thrown in /opt/lampp/htdocs/xx/SolrPHPCient/Apache/Solr/Service.php on line 364

  3. mb says:

    Iam stuck on the indexing data part

    every time i execute tthe code i get and error “Call to a member function fetch_object() on a non-object in ” for the code line below

    while ($result = $results->fetch_object())

    please help as iam stuck on this for a long time
    thanks in advance

  4. Pawan Kumar says:

    Very good, awesome article, I am all done with your article
    thanks bro, you save my time alot, but few few mistake which is not a big issue

    Do you have same thing for cakePHP also ????
    You can reply me on pawan.oryxn@gmail.com

  5. Faisal Mehmood says:

    what is SOLR_NAME??

  6. vikash says:

    I have execute export.php file showing error

    Fatal error: Uncaught exception
    ‘Apache_Solr_HttpTransportException’ with message ”400′ Status: Bad
    Request’ in
    C:xampphtdocsajaximageslrSolrPhpClientApacheSolrService.php:345
    Stack trace:
    #0
    C:xampphtdocsajaximageslrSolrPhpClientApacheSolrService.php(615):
    Apache_Solr_Service->_sendRawPost(‘http://localhos…’, ‘add(‘addDocuments(Array)
    #3 {main}
    thrown in C:xampphtdocsajaximageslrSolrPhpClientApacheSolrService.php on line 345

    How to solve this?

  7. rohit says:

    Fatal error: Uncaught exception ‘Apache_Solr_HttpTransportException’ with message ”404′ Status: Not Found’ in C:xampphtdocssolr_tutSolrPhpClientApacheSolrService.php:364 Stack trace: #0 C:xampphtdocssolr_tutSolrPhpClientApacheSolrService.php(669): Apache_Solr_Service->_sendRawPost(‘http://localhos…’, ‘add(‘addDocuments(Array, false, true, true, 0) #3 {main} thrown in C:xampphtdocssolr_tutSolrPhpClientApacheSolrService.php on line 364

  8. Vikash Kumar says:

    /solr

  9. Tariq says:

    Hi Pawan
    did you find some thing for CakePHP

  10. Vamsikrishna Nelli says:

    Select returned 5 rows.

    Fatal error: Call to a member function fetch_object() on string in /opt/lampp/htdocs/vamsi/export.php on line 23

  11. Shirish Ambhore says:

    Hi,
    The article is good but at at the time of integration I got the fatal error like,

    PHP Fatal error: Uncaught exception ‘Apache_Solr_HttpTransportException’ with message ”404′ Status: Not Found’ in /var/www/solr_app/SolrPhpClient/Apache/Solr/Service.php:338nStack trace:n#0 /var/www/solr_app/SolrPhpClient/Apache/Solr/Service.php(1170): Apache_Solr_Service->_sendRawGet(‘http://localhos…’)n#1 /var/www/solr_app/results.php(29):

    Could you please me, how to fix it.

  12. Dimitrisrod says:

    Hi, after hours of trying to find the mistakes I think that I have made the right changes.

    Your fatal error comes because you should avoid waitflush() in your functions of Service.php. The patch that the author advises to use creates commit4() and optimize4() (both without the waitflush()) in your Service.php but you should also make changes in your export.php.
    So, you should :
    1.patch Service.php commit4(); and $solr->optimize4(); instead of commit and optimize in your export.php

  13. Utkarsh Agrawal says:

    Thank you for reply.
    I was using this in a project few years back.

    Anyways, thanks a lot for your suggestions, I hope someone else who runs into this problem can use your fix. :)

  14. Dimitrisrod says:

    Hi, after hours of trying to find the mistakes I think that I have made the right changes.
    You get this error because of wrong syntax in your export.php
    Variable result and results are not the right order.

    Change it to:

    while ($results = $result->fetch_object())
    {
    // For each result, create a new Solr doc
    $document = new Apache_Solr_Document();
    $document->id = $results->product_id;
    $document->description = $results->description;
    $document->name = $results->name;
    $document->price = $results->price;

    That is the right usage of result and results var.

  15. Dimitrisrod says:

    Hello, I wrote the answer to your problem above. :)

  16. Dimitrisrod says:

    Hello , the answer to your problem is the same with mines to Utkarsh Agrawal

  17. Dimitrisrod says:

    Hi, feel free to use my answer to your problem. Just check it above!

  18. Dimitrisrod says:

    Hi, the answer to your problem is the same that I wrote to Vamsikrishna Nelli above. :)

  19. Xi Chen says:

    Hi Dimitristrod,

    Can you please help to check the following error:

    Error:

    exception ‘Apache_Solr_HttpTransportException’ with message ”404′ Status: Not Found’ in /usr/share/solr-php-client-ui/Apache/Solr/Service.php:338 Stack trace: #0 /usr/share/solr-php-client-ui/Apache/Solr/Service.php(1172): Apache_Solr_Service->_sendRawGet(‘http://104.196….’) #1 /usr/share/solr-php-client-ui/index.php(859): Apache_Solr_Service->search(‘Tom Saler’, 0, 10, Array) #2 {main}

  20. Dimitrisrod says:

    Can you post your code please?

  21. Xi Chen says:

    It’s pretty large. can we communicate via email? xchen97@gmail.com
    Thanks.

  22. Deji says:

    Hello Dimitrisrod,

    I am getting the below error in my results.php

    exception ‘Apache_Solr_HttpTransportException’ with message ”404′
    Status: Not Found’ in
    /var/www/html/testsearch/SolrPhpClient/Apache/Solr/Service.php:338
    Stack trace:
    #0 /var/www/html/testsearch/SolrPhpClient/Apache/Solr/Service.php(1210):
    Apache_Solr_Service->_sendRawGet(‘http://146.185….’)
    #1 /var/www/html/testsearch/results.php(22):
    Apache_Solr_Service->search(‘ayo’, 0, 10)
    #2 {main}

    How can I fix this. I do no understand the fix you posted @Utkarsh Agrawal

    Thank you.

  23. Dimitrisrod says:

    This means that either your Solr is not running or your Service.php of SolrPhpClient is not working.
    Also check you have the right paths. And Service.php patched as said in this article.

  24. Rhonda says:

    I loved as much as you will receive carried out right here. The sketch is attractive, your authored material stylish. nonetheless, you command get bought an nervousness over that you wish be delivering the following. unwell unquestionably come more formerly again as exactly the same nearly very often inside case you shield this increase.

Leave a Reply

Your email address will not be published. Required fields are marked *