我有一个产品目录,并正在努力搜索它。我决定使用Algolia搜索。我可以把我的火力数据库上传到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字段。
如何在autocomplete中获取被点击对象的Algolia快照(类似于firebase快照)?这是否真的可以做到呢?
发布于 2017-10-30 09:08:43
您应该能够监听autocomplete:selected
事件,该事件在索引中具有完整的数据。
https://stackoverflow.com/questions/46983618
复制相似问题