简体   繁体   English

如何通过Elastica使用ES插件MongoDB河将MongoDB与Elastic Search连接起来

[英]How to connect MongoDB with Elastic Search using the ES plugin MongoDB river via Elastica

i'm new to programming, so i apologize, if my question is very simple. 我是编程的新手,所以我很抱歉,如果我的问题非常简单。

First of all, I have installed and configured MongoDB and ES with MongoDB river, but i can't find how to do it via Elastica. 首先,我已经使用MongoDB河安装和配置了MongoDB和ES,但是我找不到如何通过Elastica来做到这一点。 My example is 我的例子是

curl -XPUT 'http://localhost:9200/_river/mongodb/_meta' -d '{ 
"type": "mongodb", 
"mongodb": { 
    "db": "testTweets", 
    "collection": "msgs"
}, 
"index": {
    "name": "mongoindex", 
    "type": "my_type" 
}
}'

and also a query is 还有一个查询

curl -XGET 'http://localhost:9200/mongoindex/_search?q=something&pretty=true'

How can i write them using PHP and Elastica? 如何使用PHP和Elastica编写它们?

I took as example 我举了例子

$elasticaType = $elasticaIndex->getType('tweet');

and i can't find how to match the curl command with the right php code. 我找不到如何匹配curl命令与正确的PHP代码。

I hope to be crystal clear! 我希望能够清楚明白! If you need any other to detail to give my a help, i will be very happy to add it. 如果您需要任何其他细节来提供帮助,我将非常乐意添加它。

Thank you in advance! 先感谢您!

EDIT*** 编辑***

A nice way to compose ElasticSearch analysis or mapping is the following chrome extension https://chrome.google.com/webstore/detail/sense/doinijnbnggojdlcjifpdckfokbbfpbo . 构建ElasticSearch分析或映射的一种好方法是以下chrome扩展https://chrome.google.com/webstore/detail/sense/doinijnbnggojdlcjifpdckfokbbfpbo It's very helpful for me. 这对我很有帮助。

我相信唯一的办法就是通过PHP CURL来做到这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM