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+
14export const mapCollections = (
25 collections : ( string | QueryAgentCollectionConfig ) [ ] ,
36) =>
@@ -6,9 +9,12 @@ export const mapCollections = (
69 ? collection
710 : {
811 name : collection . name ,
12+ tenant : collection . tenant ,
913 view_properties : collection . viewProperties ,
1014 target_vector : collection . targetVector ,
11- tenant : collection . tenant ,
15+ additional_filters : collection . additionalFilters
16+ ? mapFilter ( collection . additionalFilters )
17+ : undefined ,
1218 } ,
1319 ) ;
1420
@@ -24,4 +30,6 @@ export type QueryAgentCollectionConfig = {
2430 viewProperties ?: string [ ] ;
2531 /** Target vector for the query if a collection uses named vector. */
2632 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 ;
2735} ;
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