简体   繁体   中英

how to get Algolia object snapshot

I have a product listings catalogue and am trying to search through it. I decided to use Algolia search. I was able to upload my firebase database to Algolia. I now have an indice in this format

  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 is each listing ID. I then figured out how to do autocomplete search using this code

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>' ;
    }
}

});

in firebase I can use this code to get a snapshot of all the data for the id

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

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

 })

and then use the snapshot to populate my html field.

how can I get an Algolia snapshot (similar to firebase snapshot) of the clicked object in autocomplete? can this even be done?

You should be able to listen to the autocomplete:selected event, which has the complete data in the index.

see https://github.com/algolia/autocomplete.js#events

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM