2014-12-03 110 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是否是您的項目的給定要求,並且您不能輕易更改技術堆棧。

相關問題