Skip to content

How to use multiple types #122

@pranto91

Description

@pranto91

Hi, I'm a newbie and working on an ES project (Express JS+ ES+MongoDB ). I'm using https://github.com/richardwilly98/elasticsearch-river-mongodb to do the indexing. The following code is working fine for a single index and type. But I have another type with the same index name ("type" : "file_info"). Is there any way to use multiple types with the same index name ? Thanks.
For example- var type= ["stu_info", "file_info"].

var index = "studentdb";
var type = "stu_info";
ElasticSearchClient = require('elasticsearchclient');
var serverOptions = {
    host: 'localhost',
    port: 9200
};
var elasticSearchClient = new ElasticSearchClient(serverOptions);
var qryObj ={
    "query": {
        "match": {
            "_all": {
                "query": "hasan",
                "fuzziness": 0.5,
                "prefix_length": 1
            }
        }
    }
}
elasticSearchClient.search(index, type, qryObj).
        on('data', function (data) {
            // console.log(data)
            deferred.resolve(JSON.parse(data).hits.hits);
        })
        .on('error', function (err) {
            console.log(err);
            return deferred.resolve(err);
        })
        .exec();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions