Skip to content

Commit 50d22f6

Browse files
committed
Add more examples
1 parent 3178018 commit 50d22f6

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

docs/developers/applications/defining-schemas.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,14 @@ let results = Product.search({
190190
limit: 5 // get the five nearest neighbors
191191
})
192192
```
193+
This can be used in combination with other conditions as well, for example:
194+
```javascript
195+
let results = Product.search({
196+
conditions: [{ attribute: 'price', comparator: 'lt', value: 50 }],
197+
sort: { attribute: 'textEmbeddings', target: searchVector },
198+
limit: 5 // get the five nearest neighbors
199+
})
200+
```
193201

194202
HNSW supports several additional arguments to the `@indexed` directive to adjust the HNSW parameters:
195203
* `distance` - Define the distance function. This can be set to 'euclidean' or 'cosine' (uses negative of cosine similarity). The default is cosine.
@@ -198,6 +206,14 @@ HNSW supports several additional arguments to the `@indexed` directive to adjust
198206
* `optimizeRouting` - This uses a heuristic to avoid graph connections that match existing indirect connections (connections through another node). This can yield more efficient graph traversals for the same M setting. This is a number between 0 and 1 and a higher value will more aggressively omit connections with alternate paths. Setting this to 0 will disable route optimizing and follow the traditional HNSW algorithm for creating connections. The default is 0.5.
199207
* `mL` - The normalization factor for level generation, by default this is computed from `M`.
200208
* `efSearchConstruction` - Maximum number of nodes to keep in the list for finding nearest neighbors for searching. The default is 50.
209+
210+
For exmpale
211+
```graphql
212+
type Product @table {
213+
id: Long @primaryKey
214+
textEmbeddings: [Float] @indexed(type: "HNSW", distance: "euclidean", optimizeRouting: 0, efSearchConstruction: 100)
215+
}
216+
```
201217

202218
#### `@createdTime`
203219

0 commit comments

Comments
 (0)