Show More Show Less
View Video Transcript
0:09
Hello everyone. In this video, we are
0:12
going to see how to do hybrid search in
0:16
Salesforce Apex.
0:19
In Salesforce, we create agent force
0:22
data library. For example, here I have
0:26
made use of uh knowledge articles as the
0:29
source for my agent force data library.
0:34
And this is my search index which was
0:37
created by default. If I wanted to use
0:41
this, I can make use of it in an agent
0:44
force agent or I can also make use of it
0:49
in a prompt template. In the prompt
0:52
template, I can uh refer custom uh the
0:55
retriever and then I will be able to
0:58
reference this search index in my prompt
1:01
template. In order to do the same in
1:04
Salesforce Apex,
1:06
we can invoke a prompt template and in
1:10
the prompt template make use of this uh
1:12
search index retriever using which we
1:15
will be able to invoke it. But the other
1:19
option we are going to see today is
1:24
running
1:26
hybrid search on the data 360 instance.
1:33
So here I created a Salesforce Apex
1:37
class. The name is knowledge search
1:39
service. Here
1:42
the search index uh
1:46
table is uh this one and the chunk table
1:49
is this one. In order to
1:52
get this name, open your uh search index
1:57
and get the
2:00
configuration name
2:09
and also you should be able to see
2:13
the same uh value under index data model
2:18
object. So this is the data model object
2:21
API name. So you can use that as the
2:27
index table and for the chunk instead of
2:29
index you can use a chunk.
2:32
I am making use of uh join query so that
2:37
I can get the source record ID field
2:40
chunk information and the hybrid score
2:44
and with the help of hybrid search
2:46
method I will be able to pass the table
2:51
index table and as well as
2:54
the chunk table so that it will join the
2:58
records and then it I will be able to
3:00
get the relevant information. So this
3:02
hybrid search is a significant method in
3:05
uh doing this using connect API CDP
3:10
query input.
3:12
I am creating a input variable.
3:15
In order to pass the data 360sql
3:19
I have to make use of connect API cdp
3:22
query input.sql.
3:24
So the SQL query is passed using connect
3:28
API.cdpquery.query
3:30
query and CSQL version two. Previously
3:32
it was not having version two. Now we
3:35
have the latest one version two where we
3:37
can pass the connect API CDP query input
3:41
with the SQL and then it will execute
3:45
that SQL query and then we will be able
3:47
to get the chunk information here in we
3:51
will be able to get
3:53
the source record ID chunk and the
3:56
hybrid score.
3:58
So this class is available in my blog
4:00
post. You can use this as a reference in
4:04
developer console. I'm going to
4:07
invoke this apex class knowledge service
4:11
and the method perform hybrid search.
4:14
Here I'm going to pass the search string
4:16
as expedite order language as encore
4:22
US. So this is the filter class
4:26
and uh five is the result limit.
4:34
This hybrid search method looks for
4:37
table
4:40
search string filter clause and the
4:44
limit.
4:45
Okay. So, this one will let me execute.
4:54
Let's open the raw log.
4:57
So, here I am able to get
5:02
source record ID
5:05
chunk
5:07
and as well as the hybrid score. Higher
5:12
the hybrid score, higher the relevancy
5:15
of information.
5:18
So this is not very relevant to expedite
5:21
order query. So the hybrid score is 0.6.
5:25
This is exactly the information I'm I
5:28
was looking for from the knowledge
5:30
article. So the hybrid score is one
5:32
which is very very high.
5:37
So if you want to do a hybrid search
5:40
using Salesforce Apex then you can make
5:42
use of this a uh blog post as your
5:45
reference.
5:46
In the blog post I have shared the apex
5:49
code
5:51
which you can refer it for your
5:53
implementation purpose.
5:58
Please check the video description. In
6:00
the video description I have shared my
6:02
blog post.
6:08
I hope it was helpful.
6:15
Thank you for watching.
#Internet Software
#Science
