我是一个新手,正在做一个ES项目(Express JS+ ES+MongoDB )。我正在使用https://github.com/richardwilly98/elasticsearch-river-mongodb进行索引。下面的代码可以很好地处理单个索引和类型。但是我有另一个具有相同索引名的类型(" type“:"file_info")。有没有办法使用具有相同索引名的多个类型?例如- var type= "stu_info","file_info“。
var index = "studentdb";
var type = "stu_info";
var elasticSearchClient = new ElasticSearchClient(serverOptions);
elasticSearchClient.search(index, type, qryObj).
on('data', function (data) {
console.log(data)
})发布于 2015-05-04 18:08:17
只需使用逗号连接类型:
var type = 'my_type,my_other_type,my_third_type';
elasticSearchClient.search('my_index_name', type, qryObj)
.on('data', function(data) {
console.log(JSON.parse(data))
})
.exec();发布于 2016-03-25 11:17:05
Elasticsearch.js接口有search方法。
- :String,String[],Boolean type要搜索的文档类型的逗号分隔列表;保留为空可对所有类型执行操作。
https://stackoverflow.com/questions/28491969
复制相似问题