> For the complete documentation index, see [llms.txt](https://kushagras-learning.gitbook.io/solr9_nested_and_graph/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kushagras-learning.gitbook.io/solr9_nested_and_graph/nested-queries-and-graph-queries.md).

# Nested Queries and Graph Queries

To understand in which scenario we can use nested document query and graph query we have taken example of social media platform. For the demo purpose we will be using three cores namely users, posts, comments.&#x20;

Before we dive into the example let's understand what does nested and graph queries in solr.&#x20;

**Nested documents**

Nested documents refer to a data modeling approach where documents can contain other  documents as fields, forming a hierarchical or nested structure within a single document. This allows for the representation of complex, nested relationships between entities within a single indexed document.&#x20;

Nested documents enable the storage of hierarchical data structures within a single document, allowing for the representation of one-to-many or many-to-many relationships.

**Graph queries**

Graph queries involve traversing and analyzing relationships between entities represented as nodes and edges in a graph data structure. These queries enable the exploration of connections, patterns, and paths within a graph, facilitating complex data analysis and retrieval.

Graph queries involve querying and analyzing relationships between entities represented as nodes and edges in a graph data structure. These queries enable the exploration of connections and patterns within the graph, facilitating complex data analysis and retrieval.

To summarize this, nested documents are a data modeling approach that allows for representing hierarchical relationships within a single document, while graph queries involve traversing and analyzing relationships between entities represented in a graph data structure. Both approaches are valuable in different contexts and can be used to model and query complex relationships within data.
