繁体   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