ElasticSearch批量(mget)查询

一、批量(mget)查询

1.1 不同索引

POST 'http://localhost:9200/_mget?pretty/'
{
    "docs": [{
        "_index": "index1",
        "_type": "type1",
        "_id": "1"
    }, {
        "_index": "index2",
        "_type": "type2",
        "_id": "3"
    }]
}

1.2 相同索引

// 相同index不同type
POST 'http://localhost:9200/index1/_mget?pretty'
{
    "docs": [{
        "_type": "type1",
        "_id": "1"
    }, {
        "_type": "type2",
        "_id": "3"
    }]
}

// 相同index和type
POST 'http://localhost:9200/index1/type1/_mget?pretty'
{
    "docs": [{
        "_id": "1"
    }, {
        "_id": "3"
    }]
}

// 或者
{
    "ids": ["1","3"]
}

你可能感兴趣的:(数据库,elasticsearch)