2014-12-03 97 views
0

我正在使用弹性搜索,并且对此技术是新的。我想知道“如何在更新couchdb相关文档时自动更新elasticsearch索引行”? 例如 我有一个像下面 purchage分贝行如何在nodejs中使用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的数据。 我为这个数据库创建了索引。 然后我的要求是当我向couchdb添加一行时,它将使用nodejs在elasticsearch索引中更新。 预先感谢

回答

0

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

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