File size: 2,553 Bytes
3932407
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
110
111
112
113
114
115
116
117
118
119
#!/usr/bin/env bash
# This test checks that Qdrant answers to all API mentioned in README.md as expected

set -ex

# Ensure current path is project root
cd "$(dirname "$0")/../"

QDRANT_HOST=${QDRANT_HOST:-'127.0.0.1:6334'}
GRPCURL_PATH="/opt/homebrew/bin/grpcurl"

# Check if local grpcurl exists and is executable
if [ -x "$GRPCURL_PATH" ]; then
    echo "Using local grpcurl installation"
    grpcurl_base=(
        "$GRPCURL_PATH"
        "-plaintext"
        "-import-path"
        "./lib/api/src/grpc/proto"
        "-proto"
        "./lib/api/src/grpc/proto/qdrant.proto"
    )
else
    echo "Local grpcurl not found, using Docker container"
    # Define base grpcurl command for Docker in case local grpcurl is not found
    grpcurl_base=(
        "docker" "run" "--rm" "--network=host"
        "-v" "${PWD}/lib/api/src/grpc/proto:/proto"
        "fullstorydev/grpcurl"
        "-plaintext"
        "-import-path" "/proto"
        "-proto" "qdrant.proto"
    )
fi

# Add headers if they exist
if [ -n "${QDRANT_HOST_HEADERS}" ]; then
    while read h; do
        grpcurl_base+=("-H" "$h")
    done <<< $(echo "${QDRANT_HOST_HEADERS}" | jq -r 'to_entries|map("\(.key): \(.value)")[]')
fi

# Function to execute grpcurl commands
execute_grpcurl() {
    "${grpcurl_base[@]}" "$@"
}

# Upsert first point
execute_grpcurl -d '{
"collection_name": "sparse_charts",
"wait": true,
"ordering": null,
"points": [
 {
   "id": { "num": 1 },
   "vectors": {
     "vectors": {
       "vectors": {
         "keywords": {
           "document": {
             "text": "my text",
             "model": "Qdrant/bm25"
           }
         }
       }
     }
   },
   "payload": {
     "city": { "string_value": "Berlin" }
   }
 }
]
}' $QDRANT_HOST qdrant.Points/Upsert

# Upsert multiple points
execute_grpcurl -d '{
"collection_name": "sparse_charts",
"wait": true,
"ordering": null,
"points": [
 {
   "id": { "num": 1 },
   "vectors": {
     "vectors": {
       "vectors": {
         "keywords": {
           "document": {
             "text": "my text",
             "model": "Qdrant/bm25"
           }
         }
       }
     }
   },
   "payload": {
     "city": { "string_value": "Berlin" }
   }
 },
 {
   "id": { "num": 2 },
   "vectors": {
     "vectors": {
       "vectors": {
         "keywords": {
           "document": {
             "text": "my text another",
             "model": "Qdrant/bm25"
           }
         }
       }
     }
   },
   "payload": {
     "city": { "string_value": "Amsterdam" }
   }
 }
]
}' $QDRANT_HOST qdrant.Points/Upsert