Closed liminal-dog closed 2 years ago
Queries to set up Neo4j fulltext search
Run on the Neo4j database to create index
CREATE FULLTEXT INDEX chainversePortalSearchIndex
FOR (n:Note | Partnership | Entity | Proposal)
ON EACH [n.text, n.name, n.body]
GraphQL queries to return results Query
query FuzzyChainversePortalSearch($searchString: String) {
fuzzyChainversePortalSearch(searchString: $searchString) {
...on Note {
__typename
uuid
text
}
...on Partnership {
__typename
uuid
text
}
...on Response {
__typename
uuid
text
}
...on Proposal {
__typename
id
body
entity {
uuid
name
}
}
}
}
Variable
{
"searchString": "Multicoin"
}
Type definition for this FuzzyChainversePortalSearch
query included in this commit on the chainverse-frontend
repo: https://github.com/DiamondDAO/chainverse-frontend/commit/5a45dcc55e5ab3a6133eef2f818a57dd7a0d5bab
And a Loom video of this returning results: https://www.loom.com/share/b53921cd951d4692a617d99aab41ac8f
I am working on requirements for table search results now. One comment on the query constructed above -- I don't think we should return Result
blocks as results, those should be internal only until we remove them.
Based on feedback during conversation with @liminal-dog yesterday I made updates to the search query and results.
Returning Entity
nodes only
Entity
nodes (instead of Note
, Partnership
, etc like we originally started with)Name
, # of Notes relations
, # of Proposals relations
, View more
Total # of Relations
but that's more complicated to implement with GraphQL so we can save for a future iterationPath Expander Search
fuzzyChainversePortalSearch
function to have two steps:
Notes
, Proposals
, or Entity
nodes that contain the search string that was enteredEntity
with a REFERENCES
or HAS_PROPOSAL
relation between the matched node and that Entity
Modified GraphQL Type Definition
union SearchNodes = Note | Entity | Proposal
type Query {
fuzzyChainversePortalSearch(searchString: String, skip: Int, limit: Int): [SearchNodes] @cypher(
statement: """
CALL db.index.fulltext.queryNodes(
'chainversePortalSearchIndex', $searchString+'~')
YIELD node as searchResult, score
WHERE score > 0.9
WITH searchResult
CALL apoc.path.subgraphNodes(searchResult, {
relationshipFilter: 'REFERENCES|HAS_PROPOSAL',
labelFilter: '>Entity',
minLevel: 1,
maxLevel: 2
})
YIELD node as r
RETURN r
SKIP $skip LIMIT $limit
"""
)
}
type Entity {
"""
TODO: Should this be restricted
"""
uuid: ID! @id(autogenerate: true)
name: String @unique #under assumption name for entities are unique
id: String @unique
minScore: Float
network: Float
onlyMembers: String
symbol: String
address: String @unique
avatar: String
about: String
proposals: [Proposal] @relationship(type: "HAS_PROPOSAL", direction: OUT)
notes: [Note] @relationship(type: "REFERENCES", direction: IN)
}
Search Result Sample
Now this query
query FuzzyChainversePortalSearch($searchString: String, $skip: Int, $limit: Int) {
fuzzyChainversePortalSearch(searchString: $searchString, skip: $skip, limit: $limit) {
... on Entity {
uuid
name
notesAggregate {
count
}
proposalsAggregate {
count
}
}
}
}
with this variable input
{
"searchString": "investor",
"skip": 0,
"limit": 10
}
Produces a JSON structure like this
{
"data": {
"fuzzyChainversePortalSearch": [
{
"uuid": "1dfe665e-1e2e-4be7-8fb9-430bd36e40e0",
"name": "Actor DAO",
"notesAggregate": {
"count": 0
},
"proposalsAggregate": {
"count": 61
}
},
{
"uuid": "44126fbf-840f-44dc-80c5-c8d3755fb80f",
"name": "PancakeSwap",
"notesAggregate": {
"count": 0
},
"proposalsAggregate": {
"count": 587
}
},
{
"uuid": "dd4b09ef-cb03-4fec-add0-2b7ee247bd0c",
"name": "CafeSwap.Finance",
"notesAggregate": {
"count": 0
},
"proposalsAggregate": {
"count": 21
}
},
Notes
View More
link will reference the Entity.uuid
property to bring up more information about that Entity
We have a similar issue in Chainverse Portal
should we close this ticket?
moved to chainverse portal
Summary
Requirements
knowledge graph
we might see hits on multiple blocks and tags. Instead of returning blocks/tags, we should return the entities those blocks and tags are connected to.Profile
(more details inEntity Profile
)Wireframes