Fireship · @fireship

Angular 4 Full Text Search with Algolia - Part 1

Uploaded July 17, 2017 · Length 4:29

Angular 4 Full Text Search with Algolia - Part 1

Summary

Implementing full text search in Angular 4 with Algolia's Instant Search library and Firebase Cloud Functions.

  • angular 4
  • algolia
  • instant search
  • full text search
  • firebase cloud functions

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    in this episode we're going to use the

  2. 0:02

    algo Lea search platform to implement

  3. 0:04

    full text search into an angular 4

  4. 0:06

    application

  5. 0:07

    algo Lea provides a library called

  6. 0:09

    instant search Jas which we'll use to

  7. 0:11

    implement all kinds of different widgets

  8. 0:13

    into our search with very little code

  9. 0:15

    when you sign up for algo Lea it

  10. 0:18

    provides a default index of Hollywood

  11. 0:20

    actors we'll be using this index on the

  12. 0:22

    first video then in the second video

  13. 0:24

    we'll create our own custom index with

  14. 0:26

    firebase cloud functions the first step

  15. 0:29

    is to sign up for an algo Lea account

  16. 0:30

    and get your API credentials they have a

  17. 0:33

    free tier which is just limited by usage

  18. 0:36

    after you sign up you'll go through a

  19. 0:38

    new user tour and then you'll want to

  20. 0:40

    make note of your search on the API key

  21. 0:42

    and your app ID inside the angular

  22. 0:46

    project you'll run NPM install instant

  23. 0:48

    search jas instant search is an open

  24. 0:51

    source library maintained by algo Lea it

  25. 0:54

    takes care of all the front-end features

  26. 0:55

    like autocomplete pagination filtering

  27. 0:58

    and a lot more in angular I'm going to

  28. 1:01

    add my API keys to the environment file

  29. 1:03

    and specify that get started actors

  30. 1:06

    index if you want to use the instant

  31. 1:09

    search default CSS you can add that to

  32. 1:11

    the head of the index.html file now we

  33. 1:15

    can generate a new component called

  34. 1:16

    search UI component we start by

  35. 1:19

    importing the environment file and the

  36. 1:22

    instant search package we declare a

  37. 1:25

    variable search which will hold the

  38. 1:26

    entire configuration for this search

  39. 1:28

    feature then we pass it the

  40. 1:30

    configuration from the environment file

  41. 1:32

    and to initialize it we call search dot

  42. 1:35

    start at this point nothing will happen

  43. 1:38

    because we don't have any widgets

  44. 1:40

    attached to the search instance so we'll

  45. 1:42

    go ahead and give it a search box widget

  46. 1:44

    and every widget has its own

  47. 1:46

    configuration options the most important

  48. 1:48

    being the container option which points

  49. 1:51

    to an HTML element that will be replaced

  50. 1:53

    by this widget so now that we have a

  51. 1:56

    place for the user to enter their search

  52. 1:58

    we need another div that will hold the