File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change
1
+ import { FilterValue } from "weaviate-client" ;
2
+ import { mapFilter } from "./filter.js" ;
3
+
1
4
export const mapCollections = (
2
5
collections : ( string | QueryAgentCollectionConfig ) [ ] ,
3
6
) =>
@@ -6,9 +9,12 @@ export const mapCollections = (
6
9
? collection
7
10
: {
8
11
name : collection . name ,
12
+ tenant : collection . tenant ,
9
13
view_properties : collection . viewProperties ,
10
14
target_vector : collection . targetVector ,
11
- tenant : collection . tenant ,
15
+ additional_filters : collection . additionalFilters
16
+ ? mapFilter ( collection . additionalFilters )
17
+ : undefined ,
12
18
} ,
13
19
) ;
14
20
@@ -24,4 +30,6 @@ export type QueryAgentCollectionConfig = {
24
30
viewProperties ?: string [ ] ;
25
31
/** Target vector for the query if a collection uses named vector. */
26
32
targetVector ?: string | string [ ] ;
33
+ /** Filters to apply to apply when query is executed, in addition to filters selected by the Query Agent. */
34
+ additionalFilters ?: FilterValue ;
27
35
} ;
Original file line number Diff line number Diff line change
1
+ import { FilterValue , Operator } from "weaviate-client" ;
2
+
3
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
+ export const mapFilter = ( filters : FilterValue ) : any =>
5
+ filters . filters
6
+ ? {
7
+ combine : mapFilterCombineOperator ( filters . operator ) ,
8
+ filters : filters . filters . map ( mapFilter ) ,
9
+ }
10
+ : {
11
+ ...filters ,
12
+ target : filters . target ?. property ?? filters . target ,
13
+ } ;
14
+
15
+ const mapFilterCombineOperator = ( operator : Operator ) => {
16
+ switch ( operator ) {
17
+ case "And" :
18
+ return "and" ;
19
+ case "Or" :
20
+ return "or" ;
21
+ default :
22
+ return operator ;
23
+ }
24
+ } ;
You can’t perform that action at this time.
0 commit comments