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" : " nqdataset-simplified-clean-semantictext" ,
37+ "num_hits" : 10
38+ }
39+ }
0 commit comments