Skip to content

Commit d38aa6c

Browse files
authored
Update README.md
added a query example for ES 5.X
1 parent 8b21da9 commit d38aa6c

File tree

1 file changed

+48
-18
lines changed

1 file changed

+48
-18
lines changed

README.md

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,26 +45,56 @@ give it a try.
4545

4646
### Querying
4747
* For querying the 100 KNN documents use this POST message on your ES index:
48-
49-
```{
50-
"query": {
51-
"function_score": {
52-
"boost_mode": "replace",
53-
"script_score": {
54-
"lang": "knn",
55-
"params": {
56-
"cosine": false,
57-
"field": "embedding_vector",
58-
"vector": [
48+
49+
50+
For ES 5.X:
51+
```
52+
{
53+
"query": {
54+
"function_score": {
55+
"boost_mode": "replace",
56+
"script_score": {
57+
"script": {
58+
"inline": "binary_vector_score",
59+
"lang": "knn",
60+
"params": {
61+
"cosine": false,
62+
"field": "embedding_vector",
63+
"vector": [
5964
-0.09217305481433868, 0.010635560378432274, -0.02878434956073761, 0.06988169997930527, 0.1273992955684662, -0.023723633959889412, 0.05490724742412567, -0.12124507874250412, -0.023694118484854698, 0.014595639891922474, 0.1471538096666336, 0.044936809688806534, -0.02795785665512085, -0.05665992572903633, -0.2441125512123108, 0.2755320072174072, 0.11451690644025803, 0.20242854952812195, -0.1387604922056198, 0.05219579488039017, 0.1145530641078949, 0.09967200458049774, 0.2161576747894287, 0.06157230958342552, 0.10350126028060913, 0.20387393236160278, 0.1367097795009613, 0.02070528082549572, 0.19238869845867157, 0.059613026678562164, 0.014012521132826805, 0.16701748967170715, 0.04985826835036278, -0.10990987718105316, -0.12032567709684372, -0.1450948715209961, 0.13585780560970306, 0.037511035799980164, 0.04251480475068092, 0.10693439096212387, -0.08861573040485382, -0.07457160204648972, 0.0549330934882164, 0.19136285781860352, 0.03346432000398636, -0.03652812913060188, -0.1902569830417633, 0.03250952064990997, -0.3061246871948242, 0.05219300463795662, -0.07879918068647385, 0.1403723508119583, -0.08893408626317978, -0.24330253899097443, -0.07105310261249542, -0.18161986768245697, 0.15501035749912262, -0.216160386800766, -0.06377710402011871, -0.07671763002872467, 0.05360138416290283, -0.052845533937215805, -0.02905619889497757, 0.08279753476381302
6065
]
61-
},
62-
"script": "binary_vector_score"
63-
}
64-
}
65-
},
66-
"size": 100
67-
}
66+
}
67+
}
68+
}
69+
}
70+
},
71+
"size": 100
72+
}
73+
```
74+
75+
76+
For ES 2.X:
77+
78+
```
79+
{
80+
"query": {
81+
"function_score": {
82+
"boost_mode": "replace",
83+
"script_score": {
84+
"lang": "knn",
85+
"params": {
86+
"cosine": false,
87+
"field": "embedding_vector",
88+
"vector": [
89+
-0.09217305481433868, 0.010635560378432274, -0.02878434956073761, 0.06988169997930527, 0.1273992955684662, -0.023723633959889412, 0.05490724742412567, -0.12124507874250412, -0.023694118484854698, 0.014595639891922474, 0.1471538096666336, 0.044936809688806534, -0.02795785665512085, -0.05665992572903633, -0.2441125512123108, 0.2755320072174072, 0.11451690644025803, 0.20242854952812195, -0.1387604922056198, 0.05219579488039017, 0.1145530641078949, 0.09967200458049774, 0.2161576747894287, 0.06157230958342552, 0.10350126028060913, 0.20387393236160278, 0.1367097795009613, 0.02070528082549572, 0.19238869845867157, 0.059613026678562164, 0.014012521132826805, 0.16701748967170715, 0.04985826835036278, -0.10990987718105316, -0.12032567709684372, -0.1450948715209961, 0.13585780560970306, 0.037511035799980164, 0.04251480475068092, 0.10693439096212387, -0.08861573040485382, -0.07457160204648972, 0.0549330934882164, 0.19136285781860352, 0.03346432000398636, -0.03652812913060188, -0.1902569830417633, 0.03250952064990997, -0.3061246871948242, 0.05219300463795662, -0.07879918068647385, 0.1403723508119583, -0.08893408626317978, -0.24330253899097443, -0.07105310261249542, -0.18161986768245697, 0.15501035749912262, -0.216160386800766, -0.06377710402011871, -0.07671763002872467, 0.05360138416290283, -0.052845533937215805, -0.02905619889497757, 0.08279753476381302
90+
]
91+
},
92+
"script": "binary_vector_score"
93+
}
94+
}
95+
},
96+
"size": 100
97+
}
6898
```
6999
* The example above shows a vector of 64 dimensions
70100
* Parameters:

0 commit comments

Comments
 (0)