Second half of Algolia Full Text Search with Angular 4 and Firebase Cloud Functions. In this video we create a cloud function to keep a searchable index updated with the realtime database. Full lesson: https://angularfirebase.com/lessons/angular-full-text-search-with-algolia-backend-part-2/

Check out the first half of this lesson: https://youtu.be/4u_Vd-c9uLI
2024-02-04T08:22:07.841Z
nova-2
2-general-nova
2024-01-09.29447
30089e05-99d1-4376-b32e-c263170674af
815f3590-e5ba-479a-8903-5042dd11f62d
d4af3ff5e0a012a8605f055845e1d7860815cb57091e1c7f304c19deae24e374
67875a7f-c9c4-48a0-aa55-5bdb8a91c34a
deprecated
Now that we know how to implement Algolia search on the front end, we're going to create a Firebase Cloud function to build our own custom index on the back end.
In this example, we will create an index of books from the Google Books API.
Anytime this book data changes on the database, It will automatically invoke the function, telling Algolia to update the index.
The first step is to create a new index on the Algolia dashboard.
In this case, we'll just call it books.
This.
Currently, the index is empty, but when we add new data to the Firebase database, we wanna see the index updated with that new data.
So if we add a new book to Firebase, then go back to Algolia, we should see that book in the index.
Now let's see how we make this possible with Firebase Cloud Functions.
The first initialize functions in your project, then cd into the functions directory.
Then install Algolia by running npm install algolia search.
Then set your Algolia API keys in the functions environment.
You'll want to make sure to use the admin API key.
In the index dot JS file, we start by importing the Firebase Admin and then initialize Algolia search with the API keys that we just set.
The name of the function will be update index, and it will run anytime data is written to this node in the database, which is books slash book id.
We We reference the index by calling init index then pass the name we defined in the Algolia dashboard.
Then we set a variable for the data in the Firebase database.
Then we set the Algolia object ID to whatever the book ID happens to be.
Every record in your Algolia index is required to have a unique object ID.
In most cases you'd want to use the Firebase push key.
You can add new data to the index by calling index dot save object and then pass it that data object.
It.
Then you have a callback from which you can catch the error, or in this case, we just console log the success of the update.
So far, the function will only work when data is created or the data.
So we check to see if the data variable is empty, and if so we call the delete object method instead.
After you deploy the function, you should see the Cloud Function logs being updated each time a new book is added or removed to the database.
Back in the Angular front end, the only thing we need to change is the index name, pointing it to the books index.
Going into the app, we can test it out and make sure that filters that have books in our index.
That's it for full text search with Algolia.
If this video helped you, please like and subscribe.
And if you wanna support the channel, consider becoming a pro member at angularfirebase.com.
You'll receive free 1 on 1 project consulting as well as a copy of the Angular Firebase survival guide.
Thanks for watching, and I'll see you next time.

Speaker 0: Now that we know how to implement Algolia search on the front end, we're going to create a Firebase Cloud function to build our own custom index on the back end. In this example, we will create an index of books from the Google Books API. Anytime this book data changes on the database, It will automatically invoke the function, telling Algolia to update the index. The first step is to create a new index on the Algolia dashboard. In this case, we'll just call it books.

This. Currently, the index is empty, but when we add new data to the Firebase database, we wanna see the index updated with that new data. So if we add a new book to Firebase, then go back to Algolia, we should see that book in the index. Now let's see how we make this possible with Firebase Cloud Functions. The first initialize functions in your project, then cd into the functions directory.

Then install Algolia by running npm install algolia search. Then set your Algolia API keys in the functions environment. You'll want to make sure to use the admin API key. In the index dot JS file, we start by importing the Firebase Admin and then initialize Algolia search with the API keys that we just set. The name of the function will be update index, and it will run anytime data is written to this node in the database, which is books slash book id.

We We reference the index by calling init index then pass the name we defined in the Algolia dashboard. Then we set a variable for the data in the Firebase database. Then we set the Algolia object ID to whatever the book ID happens to be. Every record in your Algolia index is required to have a unique object ID. In most cases you'd want to use the Firebase push key.

You can add new data to the index by calling index dot save object and then pass it that data object. It. Then you have a callback from which you can catch the error, or in this case, we just console log the success of the update. So far, the function will only work when data is created or the data. So we check to see if the data variable is empty, and if so we call the delete object method instead.

After you deploy the function, you should see the Cloud Function logs being updated each time a new book is added or removed to the database. Back in the Angular front end, the only thing we need to change is the index name, pointing it to the books index. Going into the app, we can test it out and make sure that filters that have books in our index. That's it for full text search with Algolia. If this video helped you, please like and subscribe.

And if you wanna support the channel, consider becoming a pro member at angularfirebase.com. You'll receive free 1 on 1 project consulting as well as a copy of the Angular Firebase survival guide. Thanks for watching, and I'll see you next time.
Now that we know how to implement Algolia search on the front end, we're going to create a Firebase Cloud function to build our own custom index on the back end. In this example, we will create an index of books from the Google Books API. Anytime this book data changes on the database, It will automatically invoke the function, telling Algolia to update the index. The first step is to create a new index on the Algolia dashboard. In this case, we'll just call it books. This. Currently, the index is empty, but when we add new data to the Firebase database, we wanna see the index updated with that new data. So if we add a new book to Firebase, then go back to Algolia, we should see that book in the index. Now let's see how we make this possible with Firebase Cloud Functions. The first initialize functions in your project, then cd into the functions directory. Then install Algolia by running npm install algolia search. Then set your Algolia API keys in the functions environment. You'll want to make sure to use the admin API key. In the index dot JS file, we start by importing the Firebase Admin and then initialize Algolia search with the API keys that we just set. The name of the function will be update index, and it will run anytime data is written to this node in the database, which is books slash book id. We We reference the index by calling init index then pass the name we defined in the Algolia dashboard. Then we set a variable for the data in the Firebase database. Then we set the Algolia object ID to whatever the book ID happens to be. Every record in your Algolia index is required to have a unique object ID. In most cases you'd want to use the Firebase push key. You can add new data to the index by calling index dot save object and then pass it that data object.
It. Then you have a callback from which you can catch the error, or in this case, we just console log the success of the update. So far, the function will only work when data is created or the data. So we check to see if the data variable is empty, and if so we call the delete object method instead.
data
After you deploy the function, you should see the Cloud Function logs being updated each time a new book is added or removed to the database. Back in the Angular front end, the only thing we need to change is the index name, pointing it to the books index. Going into the app, we can test it out and make sure that filters that have books in our index.
That's it for full text search with Algolia. If this video helped you, please like and subscribe. And if you wanna support the channel, consider becoming a pro member at angularfirebase.com. You'll receive free 1 on 1 project consulting as well as a copy of the Angular Firebase survival guide.
youtube
Thanks for watching, and I'll see you next time.
Now that we know how to implement Algolia search on the front end, we're going to create a Firebase Cloud function to build our own custom index on the back end. In this example, we will create an index of books from the Google Books API. Anytime this book data changes on the database, It will automatically invoke the function, telling Algolia to update the index. The first step is to create a new index on the Algolia dashboard. In this case, we'll just call it books. This. Currently, the index is empty, but when we add new data to the Firebase database, we wanna see the index updated with that new data. So if we add a new book to Firebase, then go back to Algolia, we should see that book in the index. Now let's see how we make this possible with Firebase Cloud Functions. The first initialize functions in your project, then cd into the functions directory. Then install Algolia by running npm install algolia search. Then set your Algolia API keys in the functions environment. You'll want to make sure to use the admin API key. In the index dot JS file, we start by importing the Firebase Admin and then initialize Algolia search with the API keys that we just set. The name of the function will be update index, and it will run anytime data is written to this node in the database, which is books slash book id. We We reference the index by calling init index then pass the name we defined in the Algolia dashboard. Then we set a variable for the data in the Firebase database. Then we set the Algolia object ID to whatever the book ID happens to be. Every record in your Algolia index is required to have a unique object ID. In most cases you'd want to use the Firebase push key. You can add new data to the index by calling index dot save object and then pass it that data object. It. Then you have a callback from which you can catch the error, or in this case, we just console log the success of the update. So far, the function will only work when data is created or the data. So we check to see if the data variable is empty, and if so we call the delete object method instead. After you deploy the function, you should see the Cloud Function logs being updated each time a new book is added or removed to the database. Back in the Angular front end, the only thing we need to change is the index name, pointing it to the books index. Going into the app, we can test it out and make sure that filters that have books in our index. That's it for full text search with Algolia. If this video helped you, please like and subscribe. And if you wanna support the channel, consider becoming a pro member at angularfirebase.com. You'll receive free 1 on 1 project consulting as well as a copy of the Angular Firebase survival guide. Thanks for watching, and I'll see you next time.
Now
now
that
that
we
we
know
know
how
how
to
to
implement
implement
Algolia
algolia
search
search
on
on
the
the
front
front
end,
end
we're
we're
going
going
to
to
create
create
a
a
Firebase
firebase
Cloud
cloud
function
function
to
to
build
build
our
our
own
own
custom
custom
index
index
on
on
the
the
back
back
end.
end
In
in
this
this
example,
example
we
we
will
will
create
create
an
an
index
index
of
of
books
books
from
from
the
the
Google
google
Books
books
API.
api
Anytime
anytime
this
this
book
book
data
data
changes
changes
on
on
the
the
database,
database
It
it
will
will
automatically
automatically
invoke
invoke
the
the
function,
function
telling
telling
Algolia
algolia
to
to
update
update
the
the
index.
index
The
the
first
first
step
step
is
is
to
to
create
create
a
a
new
new
index
index
on
on
the
the
Algolia
algolia
dashboard.
dashboard
In
in
this
this
case,
case
we'll
we'll
just
just
call
call
it
it
books.
books
This.
this
Currently,
currently
the
the
index
index
is
is
empty,
empty
but
but
when
when
we
we
add
add
new
new
data
data
to
to
the
the
Firebase
firebase
database,
database
we
we
wanna
wanna
see
see
the
the
index
index
updated
updated
with
with
that
that
new
new
data.
data
So
so
if
if
we
we
add
add
a
a
new
new
book
book
to
to
Firebase,
firebase
then
then
go
go
back
back
to
to
Algolia,
algolia
we
we
should
should
see
see
that
that
book
book
in
in
the
the
index.
index
Now
now
let's
let's
see
see
how
how
we
we
make
make
this
this
possible
possible
with
with
Firebase
firebase
Cloud
cloud
Functions.
functions
The
the
first
first
initialize
initialize
functions
functions
in
in
your
your
project,
project
then
then
cd
cd
into
into
the
the
functions
functions
directory.
directory
Then
then
install
install
Algolia
algolia
by
by
running
running
npm
npm
install
install
algolia
algolia
search.
search
Then
then
set
set
your
your
Algolia
algolia
API
api
keys
keys
in
in
the
the
functions
functions
environment.
environment
You'll
you'll
want
want
to
to
make
make
sure
sure
to
to
use
use
the
the
admin
admin
API
api
key.
key
In
in
the
the
index
index
dot
dot
JS
js
file,
file
we
we
start
start
by
by
importing
importing
the
the
Firebase
firebase
Admin
admin
and
and
then
then
initialize
initialize
Algolia
algolia
search
search
with
with
the
the
API
api
keys
keys
that
that
we
we
just
just
set.
set
The
the
name
name
of
of
the
the
function
function
will
will
be
be
update
update
index,
index
and
and
it
it
will
will
run
run
anytime
anytime
data
data
is
is
written
written
to
to
this
this
node
node
in
in
the
the
database,
database
which
which
is
is
books
books
slash
slash
book
book
id.
id
We
we
We
we
reference
reference
the
the
index
index
by
by
calling
calling
init
init
index
index
then
then
pass
pass
the
the
name
name
we
we
defined
defined
in
in
the
the
Algolia
algolia
dashboard.
dashboard
Then
then
we
we
set
set
a
a
variable
variable
for
for
the
the
data
data
in
in
the
the
Firebase
firebase
database.
database
Then
then
we
we
set
set
the
the
Algolia
algolia
object
object
ID
id
to
to
whatever
whatever
the
the
book
book
ID
id
happens
happens
to
to
be.
be
Every
every
record
record
in
in
your
your
Algolia
algolia
index
index
is
is
required
required
to
to
have
have
a
a
unique
unique
object
object
ID.
id
In
in
most
most
cases
cases
you'd
you'd
want
want
to
to
use
use
the
the
Firebase
firebase
push
push
key.
key
You
you
can
can
add
add
new
new
data
data
to
to
the
the
index
index
by
by
calling
calling
index
index
dot
dot
save
save
object
object
and
and
then
then
pass
pass
it
it
that
that
data
data
object.
object
It.
it
Then
then
you
you
have
have
a
a
callback
callback
from
from
which
which
you
you
can
can
catch
catch
the
the
error,
error
or
or
in
in
this
this
case,
case
we
we
just
just
console
console
log
log
the
the
success
success
of
of
the
the
update.
update
So
so
far,
far
the
the
function
function
will
will
only
only
work
work
when
when
data
data
is
is
created
created
or
or
the
the
data.
data
So
so
we
we
check
check
to
to
see
see
if
if
the
the
data
data
variable
variable
is
is
empty,
empty
and
and
if
if
so
so
we
we
call
call
the
the
delete
delete
object
object
method
method
instead.
instead
After
after
you
you
deploy
deploy
the
the
function,
function
you
you
should
should
see
see
the
the
Cloud
cloud
Function
function
logs
logs
being
being
updated
updated
each
each
time
time
a
a
new
new
book
book
is
is
added
added
or
or
removed
removed
to
to
the
the
database.
database
Back
back
in
in
the
the
Angular
angular
front
front
end,
end
the
the
only
only
thing
thing
we
we
need
need
to
to
change
change
is
is
the
the
index
index
name,
name
pointing
pointing
it
it
to
to
the
the
books
books
index.
index
Going
going
into
into
the
the
app,
app
we
we
can
can
test
test
it
it
out
out
and
and
make
make
sure
sure
that
that
filters
filters
that
that
have
have
books
books
in
in
our
our
index.
index
That's
that's
it
it
for
for
full
full
text
text
search
search
with
with
Algolia.
algolia
If
if
this
this
video
video
helped
helped
you,
you
please
please
like
like
and
and
subscribe.
subscribe
And
and
if
if
you
you
wanna
wanna
support
support
the
the
channel,
channel
consider
consider
becoming
becoming
a
a
pro
pro
member
member
at
at
angularfirebase.com.
angularfirebase.com
You'll
you'll
receive
receive
free
free
1
1
on
on
1
1
project
project
consulting
consulting
as
as
well
well
as
as
a
a
copy
copy
of
of
the
the
Angular
angular
Firebase
firebase
survival
survival
guide.
guide
Thanks
thanks
for
for
watching,
watching
and
and
I'll
i'll
see
see
you
you
next
next
time.
time
success
The speaker explains how to implement the Algolia search on the front end and create a custom index on the back end. They recommend importing the Azure Admin and initializing the search function, setting keys in the functions environment, and setting the AWS API keys. The index is currently empty, but when new data is added to the database, it should update with the index. The Cloud function logs will be updated each time a new book is added or removed to the database, and the Cloud Function logs will be used to check if the data variable is empty or called the delete object method.
Algolia with Firebase Cloud Functions - Part 2
Now that we know how to implement Algolia search on the front end, we're going to create a Firebase Cloud function to build our own custom index on the back end. In this example, we will create an index of books from the Google Books API. Anytime this book data changes on the database, It will automatically invoke the function, telling Algolia to update the index. The first step is to create a new index on the Algolia dashboard. In this case, we'll just call it books. This. Currently, the index is empty, but when we add new data to the Firebase database, we wanna see the index updated with that new data. So if we add a new book to Firebase, then go back to Algolia, we should see that book in the index. Now let's see how we make this possible with Firebase Cloud Functions. The first initialize functions in your project, then cd into the functions directory. Then install Algolia by running npm install algolia search. Then set your Algolia API keys in the functions environment. You'll want to make sure to use the admin API key. In the index dot JS file, we start by importing the Firebase Admin and then initialize Algolia search with the API keys that we just set. The name of the function will be update index, and it will run anytime data is written to this node in the database, which is books slash book id. We We reference the index by calling init index then pass the name we defined in the Algolia dashboard. Then we set a variable for the data in the Firebase database. Then we set the Algolia object ID to whatever the book ID happens to be. Every record in your Algolia index is required to have a unique object ID. In most cases you'd want to use the Firebase push key. You can add new data to the index by calling index dot save object and then pass it that data object. It. Then you have a callback from which you can catch the error, or in this case, we just console log the success of the update. So far, the function will only work when data is created or the data. So we check to see if the data variable is empty, and if so we call the delete object method instead. After you deploy the function, you should see the Cloud Function logs being updated each time a new book is added or removed to the database. Back in the Angular front end, the only thing we need to change is the index name, pointing it to the books index. Going into the app, we can test it out and make sure that filters that have books in our index. That's it for full text search with Algolia. If this video helped you, please like and subscribe. And if you wanna support the channel, consider becoming a pro member at angularfirebase.com. You'll receive free 1 on 1 project consulting as well as a copy of the Angular Firebase survival guide. Thanks for watching, and I'll see you next time.
The speaker explains how to implement the Algolia search on the front end and create a custom index on the back end. They recommend importing the Azure Admin and initializing the search function, setting keys in the functions environment, and setting the AWS API keys. The index is currently empty, but when new data is added to the database, it should update with the index. The Cloud function logs will be updated each time a new book is added or removed to the database, and the Cloud Function logs will be used to check if the data variable is empty or called the delete object method.