This is a continuation to the introductory article on Building and Querying Knowledge graphs with Apache Age.As we concluded in the last article we learnt that we can be able to create complex knowledge graph on Apache AGE .in this article we will continue where we left from and discuss more about semantic searches in Apache AGE and what it entails
What are semantic searches in graphs?
Semantic search refers to a search technique that aims to retrieve information from a graph database or knowledge graph based on the meaning or context of the query rather than just relying on exact matches of keywords. It involves understanding the relationships and connections between nodes (entities) in the graph to provide more accurate and relevant search results.
Practical examples of semantics searches in knowledge graphs include:
- Traversing Relationships.
- Pattern matching.
- Discovering patterns.
Sample implementation of semantic searches in Apache AGE
1.Traversing Relationships
In traversing relationships we can traverse relationships in graph queries to find related entities.
example traversing relationship in AGE can be:
SELECT * FROM cypher('purchases', $$
MATCH (:store {name: 'Platform'})-[r]->(products)
RETURN type(r)
$$) as (products agtype);
The following query is to be able to understand the relationship between A shoe store and the products they sell.
2.Pattern Matching
In pattern matching we can discover complex relationships by finding paths between entities involving multiple intermediate nodes
example of pattern matching Apache AGE can be:
SELECT *
FROM cypher('purchases', $$
MATCH (a {name: 'store'})-[r]->(brands)
WHERE n.store = 'Platform'
RETURN r
$$) as (r agtype);
The following query will find store that have relationship with various products and brands.
Discovering patterns.
Discovering patterns helps in identifying recurring patterns in particular use case to help understand what are the best options from the use case.
sample example in Apache AGE can be:
In case of a shoe store we can check which are the frequently most bought brand by customers in a particular and this can be done like so in Apache AGE:
SELECT *
FROM cypher('purchases', $$
MATCH (n)
WITH n.store as store, n.products as products
ORDER BY n.brand,
RETURN name, brands
$$) as (name agtype, products agtype);
The following query will discover patterns of various properties and output results of brands that are most frequently sold by a particular store.
In conclusion to be able to represent complex relationships and facilitate semantic searches empowers us to navigate and understand in depth and intricate domains of information and help disseminate reliable information and insights that will be helpful for serious decision making
Top comments (0)