在Windows Xampp上安装和使用elasticsearch php客户端(Installation and using elasticsearch php client on Windows Xampp)
我从https://www.elastic.co/downloads/elasticsearch下载了elasticsearch-5.1.1.zip
然后使用此命令通过composer下载用于elasticsearch的Elastica A PHP客户端
作曲家需要ruflin / elastica:dev-master
现在我想打开并进行测试。 当我运行此命令
BIN \ elasticsearch.bat
我收到此错误: 命令的语法不正确。
另一方面,如果我尝试使用Elastica A PHP客户端,我会收到如下错误:
致命错误:未捕获Elastica \ Exception \ Connection \ HttpException:无法连接到主机,Elasticsearch下来? 在E:\ xampp \ htdocs \ el \ vendor \ ruflin \ elastica \ lib \ Elastica \ Transport \ Http.php:180堆栈跟踪:#0 E:\ xampp \ htdocs \ el \ vendor \ ruflin \ elastica \ lib \ Elastica \ Request.php(171):Elastica \ Transport \ Http-> exec(Object(Elastica \ Request),Array)#1 E:\ xampp \ htdocs \ el \ vendor \ ruflin \ elastica \ lib \ Elastica \ Client.php (662):Elastica \ Request-> send()#2 E:\ xampp \ htdocs \ el \ vendor \ ruflin \ elastica \ lib \ Elastica \ Client.php(673):Elastica \ Client-> request('twitter / ','DELETE',Array,Array)#3 E:\ xampp \ htdocs \ el \ vendor \ ruflin \ elastica \ lib \ Elastica \ Index.php(531):Elastica \ Client-> request('twitter /', 'DELETE',Array,Array)#4 E:\ xampp \ htdocs \ el \ vendor \ ruflin \ elastica \ lib \ Elastica \ Index.php(165):Elastica \ Index-> request('twitter /','DELETE ')#5 E:\ xampp \ htdocs \ el \ vendor \ ruflin \ elastica \ lib \ Elastica \ Index.php(258):Elastica \ Index-> delete()#6 E:\ xampp \ htdocs \ el \ index .php(40):Elastica \ Index-> create(Array,true)#7 {main}抛出E:\ xampp \ htdocs \ el \ vendor \ ruflin \ elastica \ lib \ Elastica \ Transport \ Http.php on line 18 0
我的问题是我如何使用elasticsearch-5.1? 我哪里做错了?
问候。
I'm downloaded the elasticsearch-5.1.1.zip from the https://www.elastic.co/downloads/elasticsearch
Then download the Elastica A PHP client for elasticsearch via composer with this command
composer require ruflin/elastica:dev-master
Now i want to open and make a test. When i run this command
bin\elasticsearch.bat
i get this error: The syntax of the command is incorrect.
On the other side if i try to use Elastica A PHP client i get some errors like this:
Fatal error: Uncaught Elastica\Exception\Connection\HttpException: Couldn't connect to host, Elasticsearch down? in E:\xampp\htdocs\el\vendor\ruflin\elastica\lib\Elastica\Transport\Http.php:180 Stack trace: #0 E:\xampp\htdocs\el\vendor\ruflin\elastica\lib\Elastica\Request.php(171): Elastica\Transport\Http->exec(Object(Elastica\Request), Array) #1 E:\xampp\htdocs\el\vendor\ruflin\elastica\lib\Elastica\Client.php(662): Elastica\Request->send() #2 E:\xampp\htdocs\el\vendor\ruflin\elastica\lib\Elastica\Client.php(673): Elastica\Client->request('twitter/', 'DELETE', Array, Array) #3 E:\xampp\htdocs\el\vendor\ruflin\elastica\lib\Elastica\Index.php(531): Elastica\Client->request('twitter/', 'DELETE', Array, Array) #4 E:\xampp\htdocs\el\vendor\ruflin\elastica\lib\Elastica\Index.php(165): Elastica\Index->request('twitter/', 'DELETE') #5 E:\xampp\htdocs\el\vendor\ruflin\elastica\lib\Elastica\Index.php(258): Elastica\Index->delete() #6 E:\xampp\htdocs\el\index.php(40): Elastica\Index->create(Array, true) #7 {main} thrown in E:\xampp\htdocs\el\vendor\ruflin\elastica\lib\Elastica\Transport\Http.php on line 180
My question is How can i work with elasticsearch-5.1? Where am i do wrong?
Regards.
原文:https://stackoverflow.com/questions/41333331
最满意答案
你有没有尝试在调试模式下运行? 它可能会告诉你问题是什么。
或者尝试遵循逻辑(为窗口句柄创建一个
ArrayList<String>
,然后从列表中删除旧句柄。)如果这对您有用,请将其用作util方法并在需要时调用。 :String oldTab = driver.getWindowHandle(); try{ List<String> newTab = new ArrayList<String>(driver.getWindowHandles()); newTab.remove(oldTab); driver.switchTo().window(newTab.get(0)); } catch (Exception e) { Reporter.log("No new tab found!! " + "Number of tabs currently open = "+driver.getWindowHandles().size(), Base.DEBUG_MODE); throw e; // or do whatever you wanna do here }
如果您想创建一个静态方法来切换到新窗口并将其放到您的工具中,这是一种方法:
public static void switchToNewTab(WebDriver driver) throws Exception { String oldTab = driver.getWindowHandle(); try{ List<String> newTab = new ArrayList<String>(driver.getWindowHandles()); newTab.remove(oldTab); driver.switchTo().window(newTab.get(0)); } catch (Exception e) { Reporter.log("No new tab found!! " + "Number of tabs currently open = "+driver.getWindowHandles().size(), Base.DEBUG_MODE); throw e; } }
Did you try running in Debug mode? It may tell you what the problem is.
Or alternatively try following logic (creating an
ArrayList<String>
for window handles and then removing the old handle from list.) If that works for you, use this as a util method and call where ever needed. :String oldTab = driver.getWindowHandle(); try{ List<String> newTab = new ArrayList<String>(driver.getWindowHandles()); newTab.remove(oldTab); driver.switchTo().window(newTab.get(0)); } catch (Exception e) { Reporter.log("No new tab found!! " + "Number of tabs currently open = "+driver.getWindowHandles().size(), Base.DEBUG_MODE); throw e; // or do whatever you wanna do here }
If you wanna create a static method for switching to a new window and put this to your utils, here is one approach:
public static void switchToNewTab(WebDriver driver) throws Exception { String oldTab = driver.getWindowHandle(); try{ List<String> newTab = new ArrayList<String>(driver.getWindowHandles()); newTab.remove(oldTab); driver.switchTo().window(newTab.get(0)); } catch (Exception e) { Reporter.log("No new tab found!! " + "Number of tabs currently open = "+driver.getWindowHandles().size(), Base.DEBUG_MODE); throw e; } }
相关问答
更多-
如何使用lwjgl切换显示(How to switch displays with lwjgl)[2021-09-22]
这是我处理菜单的游戏容器之一,也许你可以从中获得有用的东西。 package catt.main; import static org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT; import static org.lwjgl.opengl.GL11.glClear; import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.Display; import catt.gameMode.Arcade; import ... -
使用jQuery或Mootools进行检测 $(window).blur(function(e) { // Do Blur Actions Here }); $(window).focus(function(e) { // Do Focus Actions Here }); source: 用户切换浏览器选项卡时的事件 USE jQuery or Mootools for detecting $(window).blur(function(e) { // Do Blur Actio ...
-
现在有一个适当的全屏API ( 由Mozilla首次提出 ,后来作为W3C提案发布)已经由Webkit(Safari 5.1 + / Chrome 15+)和Firefox(10+)实施。 这里简要介绍历史和用法示例。 请注意,IE10据称不支持API。 There's now a proper fullscreen API (first proposed by Mozilla and later released as a W3C proposal) has been implemented by Web ...
-
无法在窗口之间切换(Unable to switch among the windows)[2023-08-16]
如果你只在getWindowHandles()中看到2个窗口,那么弹出窗口可能是一个iframe。 在这种情况下,使用driver.switchTo()。frame()将焦点切换到该帧,而不是寻找一个全新的窗口。 这是关于切换方法的文档: http : //selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.html#switchTo() If you're only seeing 2 window in getWi ... -
虽然能够在Query窗口中切换数据库,但SSMS不显示数据库(SSMS not displaying databases though able to switch database in Query window)[2022-04-30]
您是否从公共角色中删除了“查看任何数据库”权限? 如果公共角色没有“查看任何数据库”权限,则帐户必须是数据库的所有者才能查看。 Have you removed the View Any Database permission from the Public role? If the Public role doesn't have the View Any Database permission an account has to be the owner of the DB to see it. -
在你的函数中,在(comint-previous-input 1)调用之后,添加以下行,它将把输入发送到shell: (comint-send-input) In your function, after the (comint-previous-input 1) call, add the following line, which will send the input to the shell: (comint-send-input)
-
你有没有尝试在调试模式下运行? 它可能会告诉你问题是什么。 或者尝试遵循逻辑(为窗口句柄创建一个ArrayList
,然后从列表中删除旧句柄。)如果这对您有用,请将其用作util方法并在需要时调用。 : String oldTab = driver.getWindowHandle(); try{ List newTab = new ArrayList (driver.getWindowHandles()); newTab. ... -
每次打开窗口时WindowHandle更改,因此您无法像这样指定它。 每次要切换时都使用循环。 另外, SwitchTo().Window(handle)返回IWebDriver实例,而不是窗口id。 为此使用driver.CurrentWindowHandle 。 // get the current active window string parentHandle = driver.CurrentWindowHandle; // open new window // switch to the n ...
-
在Selenium上切换窗口(Switch window on Selenium)[2022-04-07]
由于没有内置支持 selenium在多窗口(多选项卡)环境中工作,因此启动新驱动程序: new_driver = webdriver.PhantomJS() new_driver.set_window_size(800, 450) new_driver.get("http://www.pudim.com.br/") 此外,您当前的代码对我有用: >>> from selenium import webdriver >>> driver = webdriver.PhantomJS() >>> >>> dr ... -
那是因为clicked回调需要两个参数 将原型和功能更改为 static void crete_new_wind(GtkButton *dummy, gpointer widget); static void crete_new_wind(GtkButton *dummy, gpointer widget) { 为了在你的函数中使用第二个参数。 Thats because the clicked callback wants two parameters Change the prototype and ...