[英]How to index documents with elastic.js client?
So far I haven't found any samples of HOW the elastic.js client api ( https://github.com/fullscale/elastic.js ) can be used for indexing documents. 到目前为止,我还没有找到任何样本如何使用elastic.js客户端api( https://github.com/fullscale/elastic.js )来索引文档。 There are some clues here & there but nothing concrete yet.
这里和那里有一些线索,但没有具体的。
Can anyone provide a sample snippet of code to show how an document object can be instantiated and used to index data? 任何人都可以提供一个示例代码片段来显示如何实例化文档对象并将其用于索引数据吗?
Thanks! 谢谢!
https://gist.github.com/pulkitsinghal/5430444 https://gist.github.com/pulkitsinghal/5430444
Your gist is correct. 你的要点是正确的。
You create ejs.Document objects specifying the index, type, and optionally the id of the document you want indexed. 您可以创建ejs.Document对象,指定要索引的文档的索引,类型和可选项。 If you don't specify an id, elasticsearch will generate one for you.
如果您没有指定id,elasticsearch将为您生成一个。
You set the source to the json object you want indexed then call the doIndex method specifying a callback if needed. 您将源设置为要索引的json对象,然后调用doIndex方法,指定回调(如果需要)。 The node example does not index docs, but the angular and jquery examples show a basic example and can easily be used with the node client.
节点示例不索引文档,但angular和jquery示例显示了一个基本示例,可以轻松地与节点客户端一起使用。
https://github.com/fullscale/elastic.js/blob/master/examples/angular/js/controllers.js#L30 https://github.com/fullscale/elastic.js/blob/master/examples/angular/js/controllers.js#L30
Also have a peek at the tests: 还可以看看测试:
https://github.com/fullscale/elastic.js/blob/master/tests/index_test.js#L265 https://github.com/fullscale/elastic.js/blob/master/tests/index_test.js#L265
elastic.js nowadays only implements the Query DSL, so it can't be used for this scenario anymore. 现在,elastic.js只实现了Query DSL,所以它不能再用于这个场景了。 See this commit .
看到这个提交 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.