簡體   English   中英

如何獲取Algolia對象快照

[英]how to get Algolia object snapshot

我有一個產品目錄目錄,正在嘗試搜索它。 我決定使用Algolia搜索。 我能夠將Firebase數據庫上傳到Algolia。 我現在有這種格式的索引

  objectID:5133-01-371-1830-OkqcPp3xJwfgmNinwGsKZmAa8xt1-1508966908235
  NSN:5133-01-371-1830
  Nomenclature:COUNTERSINK
  Category:FSC 5133 - Drill Bits, Counterbores, and Countersinks: Hand and Machine
  Product_Manuf:Neol
  Ava_QTY:3
  Price:434
  ProductImageUrl:https://firebasestorage.googleapis.com
  Product_Condition:New
  SellerID:OkqcPp3x900878v6v6688g8
  Shipping_cost:3
  Shipping_option:(Std US Dom) 4 - 14 business days
  Time:10/25/2017, 5:28:28 PM  

ObjectID是每個列表ID。 然后,我想出了如何使用此代碼進行自動完成搜索

autocomplete('#aa-search-input',
{ hint: true }, {
source: autocomplete.sources.hits(index, {hitsPerPage: 5}),
displayKey: 'NSN',
templates: {
    suggestion: function(suggestion) {
      return '<span>' +
        suggestion._highlightResult.NSN.value + '</span><span>' ;
    }
}

});

在firebase中,我可以使用此代碼獲取id的所有數據的快照

 var itemdetailref = Cataloguedatabase.ref('/Listings/'+ listingID);

 return itemdetailref.once('value').then(function(snapshot){

 })

然后使用快照填充我的html字段。

如何在自動完成中獲取單擊對象的Algolia快照(類似於Firebase快照)? 甚至可以做到嗎?

您應該能夠偵聽autocomplete:selected事件,該事件在索引中具有完整的數據。

參見https://github.com/algolia/autocomplete.js#events

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM