使用Solr的用PHP [英] Using Solr with PHP

查看:298
本文介绍了使用Solr的用PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用的Solr用PHP。我已经配置我的Solr的应用程序,它的正常工作。但是我不能够与使用PHP Solr的沟通。我已经尝试了一些扩展:PECL-的Solr,Solr的-PHP客户端和日光浴室。但是,没有人能ping通,甚至我的Solr服务器。所有这一切,而我的Solr服务器可在本地主机:8080 / Solr的。我与Tomcat的窗口运行它。 (我已经检查了我的tomcat和Solr服务,所有的,而当通过PHP执行ping命令,他们是启动并运行)

I am trying to use solr with php . I have configured my solr application and it's working fine . However I am not able to communicate with solr using php . I have tried a number of extensions : pecl-solr , solr-php-client and Solarium . However none were able to even ping my solr server . All this while my solr server is available at localhost:8080/solr . I am running it on windows with tomcat . (I have checked my tomcat and solr services all the while when pinging through php , they were up and running )

我想我在这里做一些很基本的错误。请问我Solr的应用程序必须在XAMPP htdocs中?因为我有它在我的Tomcat服务器的web应用文件夹内。我真的不看它如何能有所作为,因为我特别提供的路径Solr中的PHP客户端来ping这样的:

I think I am doing something very basic wrong here . Does my solr application need to be in htdocs in xampp ? Because I have it inside the webapps folder of my tomcat server . I dont really see how it could make a difference since I specifically provided the path to ping in solr-php-client like this :

 require_once( 'Apache/Solr/service.php' );


 $solr = new Apache_Solr_Service( 'localhost', '8080', '/solr' );
  var_dump($solr) ; 
  if ( ! $solr->ping() ) {
     echo 'Solr service not responding.';
      exit;
    }

我得到'Solr的服务没有响应的消息上运行该code。有什么建议?

I get the 'Solr service not responding' message on running this code . Any suggestions ?

更新:我一直在寻找在引擎盖下,发现获取的内容,使用了下面的PHP函数:的file_get_contents
我进一步认识了,当文件位于通过URI尽可能多的服务器阻止出于安全考虑这个命令就可能会失败。这是真的为XAMPP呢?运行我的本地机器上?

Update : I was looking under the hood and found that for getting the contents , the following php function is used : file_get_contents I further came to know that when the file is located through a URI it may fail as many servers block this command because of security concerns . Is this true for xampp as well ? Running on my local machine that is ?

推荐答案

试试这个,我希望它会帮助你,&安培;它为我工作。

Try this i hope it'll helpful to you, & its working for me.

$solr = new Apache_Solr_Service( 'localhost', '8080', '/solr' );
  var_dump($solr) ; 
  if ( $solr->ping() ) {
     echo 'Solr Server Responding.';
      // your code
    }else{
      echo "Solr Server is not Running";
    }

从code只是删除 require_once('阿帕奇/ Solr的/ service.php'); 这一点。

这篇关于使用Solr的用PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆