如何在nodejs中使用elasticsearch更新couchdb时自动更新索引行

时间:2014-12-03 06:34:00

标签: node.js elasticsearch couchdb

我正在使用弹性搜索,并且是这项技术的新手。我想知道“当couchdb相关文档更新时,如何自动更新elasticsearch索引行?” 例如 我有像下面这样的couchdb数据 购买数据库行

rows:[{
           "_id": "8ea64a80b67aff0ee12393b9",
           "_rev": "3-3d76a4f82bc4d3f8f7",
           "polines": [
               {
                   "stock_enabled_flag": "Y",
                   "charge_account_id": 23397,
                   "line_type": "Material",
                   "make1": "make1",
                   "need_by_date": "2012/11/23",
                   "promised_date": "2012/11/23",
                   "quantity": 80,
                   "unit_of_measure": "BAG",
                   "unit_price": 161.00021
               }
           ]
        },
{
           "_id": "8ea64a80b67aff0ee12393b99580",
           "_rev": "3-3d76a4f82bc4d3f8f7",
           "polines": [
               {
                   "stock_enabled_flag": "Y",
                   "charge_account_id": 23397,
                   "line_type": "Material",
                   "make1": "make1",
                   "need_by_date": "2012/11/21",
                   "promised_date": "2012/11/21",
                   "quantity": 80,
                   "unit_of_measure": "BAG",
                   "unit_price": 171.00021
               }
           ]
        }
,{
           "_id": "8ea64a80b67aff0ee12393b995",
           "_rev": "3-3d76a4f82bc4d3f8f7",
           "polines": [
               {
                   "stock_enabled_flag": "Y",
                   "charge_account_id": 23397,
                   "line_type": "Material",
                   "make1": "make1",
                   "need_by_date": "2012/11/22",
                   "promised_date": "2012/11/22",
                   "quantity": 80,
                   "unit_of_measure": "BAG",
                   "unit_price": 181.00021
               }
           ]

        }]

这是我的数据。 我为这个数据库创建了索引。 然后我的要求是当我向couchdb添加一行时,它将使用nodejs在elasticsearch索引中更新。 提前谢谢

1 个答案:

答案 0 :(得分:0)

节点进程可以监听the changes feed of CouchDB。只要它检测到更改,就让它更新elasticsearch索引。

还有CouchDB Lucene可能更容易使用,但我不确定elasticsearch是否是您项目的特定要求,并且您无法轻松更改技术堆栈。