Skip to content

Commit c313b2d

Browse files
authored
Add support for semantic search to the MCP server (#45)
1 parent e75b891 commit c313b2d

File tree

5 files changed

+797
-50
lines changed

5 files changed

+797
-50
lines changed

src/mcp_server_datahub/gql/search.gql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ query search(
9090
entity {
9191
...SearchEntityInfo
9292
}
93+
# TODO: Consider adding these fields for enhanced search experience:
94+
# score # BM25 score for keyword search relevance
9395
}
9496
facets {
9597
field
@@ -103,5 +105,9 @@ query search(
103105
}
104106
}
105107
}
108+
# TODO: Consider adding metadata section for search algorithm transparency:
109+
# metadata {
110+
# scoringMethod # e.g., "BM25" vs "COSINE_SIMILARITY"
111+
# }
106112
}
107113
}
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
fragment SearchEntityInfo on Entity {
2+
urn
3+
4+
# For some entity types, the urns are not human-readable. For those,
5+
# we pull the name as well.
6+
... on Dataset {
7+
properties {
8+
name
9+
}
10+
}
11+
... on Chart {
12+
properties {
13+
name
14+
}
15+
}
16+
... on Dashboard {
17+
properties {
18+
name
19+
}
20+
}
21+
... on Container {
22+
properties {
23+
name
24+
}
25+
}
26+
... on GlossaryTerm {
27+
properties {
28+
name
29+
}
30+
}
31+
... on GlossaryNode {
32+
properties {
33+
name
34+
}
35+
}
36+
... on Domain {
37+
properties {
38+
name
39+
}
40+
}
41+
... on DataProduct {
42+
properties {
43+
name
44+
}
45+
}
46+
}
47+
48+
fragment FacetEntityInfo on Entity {
49+
... on Dataset {
50+
name
51+
properties {
52+
name
53+
}
54+
}
55+
... on Container {
56+
subTypes {
57+
typeNames
58+
}
59+
properties {
60+
name
61+
}
62+
}
63+
... on GlossaryTerm {
64+
properties {
65+
name
66+
}
67+
}
68+
}
69+
70+
query semanticSearch(
71+
$types: [EntityType!]
72+
$query: String!
73+
$orFilters: [AndFilterInput!]
74+
$count: Int!
75+
) {
76+
semanticSearchAcrossEntities(
77+
input: {
78+
query: $query
79+
count: $count
80+
types: $types
81+
orFilters: $orFilters
82+
searchFlags: { skipHighlighting: true, maxAggValues: 5 }
83+
}
84+
) {
85+
count
86+
total
87+
searchResults {
88+
entity {
89+
...SearchEntityInfo
90+
}
91+
# TODO: Consider adding these fields for enhanced semantic search experience:
92+
# score # Cosine similarity score (0-1) for semantic relevance
93+
}
94+
facets {
95+
field
96+
displayName
97+
aggregations {
98+
value
99+
count
100+
displayName
101+
entity {
102+
...FacetEntityInfo
103+
}
104+
}
105+
}
106+
# TODO: Consider adding metadata section for search algorithm transparency:
107+
# metadata {
108+
# scoringMethod # e.g., "COSINE_SIMILARITY" vs "BM25"
109+
# }
110+
}
111+
}

0 commit comments

Comments
 (0)