Skip to content

Commit eaa5796

Browse files
VertexAI grounding integration - Updated templates with the right ELSER template + minor fixes (#435)
1 parent 94bf667 commit eaa5796

File tree

3 files changed

+33
-31
lines changed

3 files changed

+33
-31
lines changed

supporting-blog-content/Cloud-Vertex-AI/search-templates/generic_kNN_search.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
kNN search with VertexAI's embeddings models configured via Elastic's Inference API
12
PUT _scripts/google-template-knn-multioutput
23
{
34
"script": {

supporting-blog-content/Cloud-Vertex-AI/search-templates/semantic_kNN_search_with_custom_dense_vector_model.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#knn template
1+
#knn template with custom multilingual dense model (chunked)
22
PUT _scripts/google-template-knn
33
{
44
"script": {
@@ -36,8 +36,8 @@ GET nqdataset-simplified-clean-semantictext-e5/_search/template
3636
{
3737
"id": "google-template-knn",
3838
"params": {
39-
"query": "italian food",
40-
"index_name": "nqdataset-simplified-clean-semantictext-e5",
39+
"query": "What's the most famous food in Italian cousine?",
40+
"index_name": "<your-index-name-here>",
4141
"num_hits": 1
4242
}
4343
}
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,39 @@
1-
PUT _scripts/google-template-knn-multioutput
1+
#ELSER sparse_vector search template with ELSER (chunked)
2+
PUT _scripts/google-template-elser
23
{
34
"script": {
45
"lang": "mustache",
56
"source": {
6-
"_source": {
7-
"excludes": [ "title_embedding", "description_embedding", "images"]
8-
},
7+
"_source": false,
98
"size": "{{num_hits}}",
10-
"knn" : [
11-
{
12-
"field": "description_embedding",
13-
"k": 5,
14-
"num_candidates": 10,
15-
"query_vector_builder": {
16-
"text_embedding": {
17-
"model_id": "googlevertexai_embeddings_004",
18-
"model_text": "{{query}}"
9+
"query": {
10+
"nested": {
11+
"path": "document_text.inference.chunks",
12+
"query":{
13+
"sparse_vector":{
14+
"field": "document_text.inference.chunks.embeddings",
15+
"inference_id":".elser-2-elasticsearch",
16+
"query":"{{query}}"
1917
}
2018
},
21-
"boost": 0.4
22-
},
23-
{
24-
"field": "title_embedding",
25-
"k": 5,
26-
"num_candidates": 10,
27-
"query_vector_builder": {
28-
"text_embedding": {
29-
"model_id": "googlevertexai_embeddings_004",
30-
"model_text": "{{query}}"
31-
}
32-
},
33-
"boost": 0.6
19+
"inner_hits": {
20+
"size": 1,
21+
"name": "{{index_name}}.document_text",
22+
"_source": "*.text"
3423
}
35-
]
24+
}
25+
}
3626
}
3727
}
38-
}
28+
}
29+
30+
#Run the ELSER chunked templated search - chunks returned, not full documents
31+
GET nqdataset-simplified-clean-semantictext/_search/template
32+
{
33+
"id": "google-template-elser",
34+
"params": {
35+
"query": "What's the most famous food in Italian cousine?",
36+
"index_name": "<your-index-name-here>",
37+
"num_hits": 10
38+
}
39+
}

0 commit comments

Comments
 (0)