1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
// This file is autogenerated, DO NOT EDIT
// mapping/types/rank-vectors.asciidoc:159
[source, python]
----
resp = client.indices.create(
index="my-rank-vectors-bit",
mappings={
"properties": {
"my_vector": {
"type": "rank_vectors",
"element_type": "bit"
}
}
},
)
print(resp)
resp1 = client.bulk(
index="my-rank-vectors-bit",
refresh=True,
operations=[
{
"index": {
"_id": "1"
}
},
{
"my_vector": [
127,
-127,
0,
1,
42
]
},
{
"index": {
"_id": "2"
}
},
{
"my_vector": "8100012a7f"
}
],
)
print(resp1)
resp2 = client.search(
index="my-rank-vectors-bit",
query={
"script_score": {
"query": {
"match_all": {}
},
"script": {
"source": "maxSimDotProduct(params.query_vector, 'my_vector')",
"params": {
"query_vector": [
[
0.35,
0.77,
0.95,
0.15,
0.11,
0.08,
0.58,
0.06,
0.44,
0.52,
0.21,
0.62,
0.65,
0.16,
0.64,
0.39,
0.93,
0.06,
0.93,
0.31,
0.92,
0,
0.66,
0.86,
0.92,
0.03,
0.81,
0.31,
0.2,
0.92,
0.95,
0.64,
0.19,
0.26,
0.77,
0.64,
0.78,
0.32,
0.97,
0.84
]
]
}
}
}
},
)
print(resp2)
----
|