6
6
7
7
import com .google .common .collect .ImmutableSet ;
8
8
import com .linkedin .common .urn .Urn ;
9
+ import com .linkedin .common .urn .UrnUtils ;
9
10
import com .linkedin .datahub .graphql .QueryContext ;
10
11
import com .linkedin .datahub .graphql .concurrency .GraphQLConcurrencyUtils ;
11
12
import com .linkedin .datahub .graphql .generated .AndFilterInput ;
25
26
import com .linkedin .metadata .query .LineageFlags ;
26
27
import com .linkedin .metadata .query .SearchFlags ;
27
28
import com .linkedin .metadata .query .filter .Filter ;
29
+ import com .linkedin .metadata .query .filter .SortCriterion ;
28
30
import com .linkedin .metadata .search .LineageSearchResult ;
31
+ import com .linkedin .metadata .service .ViewService ;
32
+ import com .linkedin .metadata .utils .elasticsearch .FilterUtils ;
29
33
import com .linkedin .r2 .RemoteInvocationException ;
34
+ import com .linkedin .view .DataHubViewInfo ;
30
35
import graphql .VisibleForTesting ;
31
36
import graphql .schema .DataFetcher ;
32
37
import graphql .schema .DataFetchingEnvironment ;
@@ -53,10 +58,13 @@ public class SearchAcrossLineageResolver
53
58
54
59
private final EntityRegistry _entityRegistry ;
55
60
61
+ private final ViewService _viewService ;
62
+
56
63
@ VisibleForTesting final Set <String > _allEntities ;
57
64
private final List <String > _allowedEntities ;
58
65
59
- public SearchAcrossLineageResolver (EntityClient entityClient , EntityRegistry entityRegistry ) {
66
+ public SearchAcrossLineageResolver (
67
+ EntityClient entityClient , EntityRegistry entityRegistry , final ViewService viewService ) {
60
68
this ._entityClient = entityClient ;
61
69
this ._entityRegistry = entityRegistry ;
62
70
this ._allEntities =
@@ -68,6 +76,8 @@ public SearchAcrossLineageResolver(EntityClient entityClient, EntityRegistry ent
68
76
this ._allEntities .stream ()
69
77
.filter (e -> !TRANSIENT_ENTITIES .contains (e ))
70
78
.collect (Collectors .toList ());
79
+
80
+ this ._viewService = viewService ;
71
81
}
72
82
73
83
private List <String > getEntityNamesFromInput (List <EntityType > inputTypes ) {
@@ -127,6 +137,13 @@ public CompletableFuture<SearchAcrossLineageResults> get(DataFetchingEnvironment
127
137
com .linkedin .metadata .graph .LineageDirection .valueOf (lineageDirection .toString ());
128
138
return GraphQLConcurrencyUtils .supplyAsync (
129
139
() -> {
140
+ final DataHubViewInfo maybeResolvedView =
141
+ (input .getViewUrn () != null )
142
+ ? resolveView (
143
+ context .getOperationContext (),
144
+ _viewService ,
145
+ UrnUtils .getUrn (input .getViewUrn ()))
146
+ : null ;
130
147
try {
131
148
log .debug (
132
149
"Executing search across relationships: source urn {}, direction {}, entity types {}, query {}, filters: {}, start: {}, count: {}" ,
@@ -138,8 +155,13 @@ public CompletableFuture<SearchAcrossLineageResults> get(DataFetchingEnvironment
138
155
start ,
139
156
count );
140
157
141
- final Filter filter =
158
+ final Filter baseFilter =
142
159
ResolverUtils .buildFilter (input .getFilters (), input .getOrFilters ());
160
+ Filter filter =
161
+ maybeResolvedView != null
162
+ ? FilterUtils .combineFilters (
163
+ baseFilter , maybeResolvedView .getDefinition ().getFilter ())
164
+ : baseFilter ;
143
165
final SearchFlags searchFlags ;
144
166
com .linkedin .datahub .graphql .generated .SearchFlags inputFlags = input .getSearchFlags ();
145
167
if (inputFlags != null ) {
@@ -150,6 +172,7 @@ public CompletableFuture<SearchAcrossLineageResults> get(DataFetchingEnvironment
150
172
} else {
151
173
searchFlags = new SearchFlags ().setFulltext (true ).setSkipHighlighting (true );
152
174
}
175
+ List <SortCriterion > sortCriteria = SearchUtils .getSortCriteria (input .getSortInput ());
153
176
LineageSearchResult salResults =
154
177
_entityClient .searchAcrossLineage (
155
178
context
@@ -162,7 +185,7 @@ public CompletableFuture<SearchAcrossLineageResults> get(DataFetchingEnvironment
162
185
sanitizedQuery ,
163
186
maxHops ,
164
187
filter ,
165
- null ,
188
+ sortCriteria ,
166
189
start ,
167
190
count );
168
191
0 commit comments