|
| 1 | +# Saved Queries |
| 2 | + |
| 3 | +How to save, load, and share graph explorations across explorer views. |
| 4 | + |
| 5 | +## What is a Saved Query? |
| 6 | + |
| 7 | +A saved query is an ordered list of graph operations — each tagged as additive (+) or subtractive (-). This is the universal unit of work across all explorer views. |
| 8 | + |
| 9 | +``` |
| 10 | ++ MATCH (c:Concept)-[r*1..1]-(n:Concept) WHERE c.concept_id = 'abc' RETURN c, r, n; |
| 11 | ++ MATCH (c:Concept)-[r*1..1]-(n:Concept) WHERE c.concept_id = 'def' RETURN c, r, n; |
| 12 | +- MATCH (c:Concept) WHERE c.concept_id = 'xyz' RETURN c; |
| 13 | +``` |
| 14 | + |
| 15 | +The `+` operator merges results into the graph. The `-` operator removes nodes and their edges. This lets you sculpt a graph by building it up and trimming it down. |
| 16 | + |
| 17 | +## Creating a Saved Query |
| 18 | + |
| 19 | +### From Smart Search (2D/3D Graph) |
| 20 | + |
| 21 | +Every action you take in the graph explorer is recorded as a step: |
| 22 | + |
| 23 | +1. **Search** for a concept — step recorded as `+ MATCH ...` |
| 24 | +2. **Right-click a node** and choose "Add Adjacent" — step recorded as `+` |
| 25 | +3. **Right-click a node** and choose "Remove from Graph" — step recorded as `-` |
| 26 | +4. **Follow** a concept (double-click) — step recorded as `+` |
| 27 | + |
| 28 | +When you have a graph you want to keep: |
| 29 | +1. Open the **Saved Queries** panel (folder icon in the left rail) |
| 30 | +2. Click **Save Exploration** |
| 31 | +3. Give it a name |
| 32 | +4. The full step sequence is saved as a replayable program |
| 33 | + |
| 34 | +### From the Cypher Editor |
| 35 | + |
| 36 | +Write `+` and `-` prefixed statements directly: |
| 37 | + |
| 38 | +``` |
| 39 | ++ MATCH (c:Concept)-[r*1..2]-(n:Concept) WHERE c.label CONTAINS 'governance' RETURN c, r, n; |
| 40 | +- MATCH (c:Concept) WHERE c.label CONTAINS 'deprecated' RETURN c; |
| 41 | +``` |
| 42 | + |
| 43 | +Save via the Saved Queries panel. |
| 44 | + |
| 45 | +### From the Block Editor |
| 46 | + |
| 47 | +Block diagrams compile to Cypher statements. Save via the panel as a block diagram definition. |
| 48 | + |
| 49 | +## Loading a Saved Query |
| 50 | + |
| 51 | +1. Open any explorer view |
| 52 | +2. Open the **Saved Queries** panel (folder icon) |
| 53 | +3. Click a saved query |
| 54 | + |
| 55 | +The system replays each statement in order, applying `+/-` operators to build the graph state. The result is identical to the original exploration. |
| 56 | + |
| 57 | +## Cross-Explorer Flow |
| 58 | + |
| 59 | +Saved queries are shared across all explorer views. Save in one, load in another: |
| 60 | + |
| 61 | +| Explorer | What it shows from the same query | |
| 62 | +|----------|-----------------------------------| |
| 63 | +| 2D Graph | Force-directed node/edge visualization | |
| 64 | +| 3D Graph | Spatial perspective of the same graph | |
| 65 | +| Cypher Editor | The `+/-` statements as editable text | |
| 66 | +| Vocabulary Analysis | Relationship type breakdown of query results | |
| 67 | +| Document Explorer | Source documents for the query's concepts | |
| 68 | +| Polarity Explorer | Semantic axis analysis of query concepts | |
| 69 | +| Embedding Landscape | Embedding space projection of query concepts | |
| 70 | + |
| 71 | +Switching views preserves the graph. The folder icon appears consistently in all rails. |
| 72 | + |
| 73 | +## Query Types |
| 74 | + |
| 75 | +Each saved query has a type that determines how it replays: |
| 76 | + |
| 77 | +| Type | Saved From | Contains | |
| 78 | +|------|-----------|----------| |
| 79 | +| `exploration` | Smart search, Cypher editor | `{ op, cypher }[]` statements | |
| 80 | +| `polarity` | Polarity explorer | Pole concept IDs + analysis params | |
| 81 | +| `block_diagram` | Block editor | ReactFlow nodes/edges layout | |
| 82 | + |
| 83 | +The Saved Queries panel shows type-aware subtitles (e.g., "3 steps" for explorations, "2 poles" for polarity). |
| 84 | + |
| 85 | +## The +/- Operator Algebra |
| 86 | + |
| 87 | +The operators work like set arithmetic on graph results: |
| 88 | + |
| 89 | +- **`+` (union)**: Execute the Cypher statement and merge its nodes/edges into the current graph. Duplicate nodes are deduplicated by ID. |
| 90 | +- **`-` (difference)**: Execute the Cypher statement and remove matching nodes from the current graph. Edges connected to removed nodes are also removed. |
| 91 | + |
| 92 | +### Example: Building a Focused Subgraph |
| 93 | + |
| 94 | +``` |
| 95 | +# Start with everything related to "governance" |
| 96 | ++ MATCH (c:Concept)-[r*1..2]-(n) WHERE c.label CONTAINS 'governance' RETURN c, r, n; |
| 97 | +
|
| 98 | +# Add concepts about "compliance" |
| 99 | ++ MATCH (c:Concept)-[r*1..1]-(n) WHERE c.label CONTAINS 'compliance' RETURN c, r, n; |
| 100 | +
|
| 101 | +# Remove noise — concepts about "legacy systems" |
| 102 | +- MATCH (c:Concept) WHERE c.label CONTAINS 'legacy' RETURN c; |
| 103 | +``` |
| 104 | + |
| 105 | +This produces a graph focused on governance + compliance, with legacy system noise trimmed out. |
| 106 | + |
| 107 | +## Exporting to Cypher |
| 108 | + |
| 109 | +From the 2D/3D graph explorer, your exploration can be sent to the Cypher editor: |
| 110 | + |
| 111 | +1. Build your graph through search and navigation |
| 112 | +2. The exploration session is automatically tracked |
| 113 | +3. Switch to the Cypher editor tab |
| 114 | +4. Your steps appear as `+/-` prefixed statements |
| 115 | +5. Edit, rearrange, or share the text |
| 116 | + |
| 117 | +The text format is designed to be copy/pasteable between users. |
| 118 | + |
| 119 | +## Document Explorer Integration |
| 120 | + |
| 121 | +The Document Explorer uses saved exploration queries differently: |
| 122 | + |
| 123 | +1. Load an exploration query |
| 124 | +2. The system finds all documents containing those concepts |
| 125 | +3. A multi-document concept graph is built automatically |
| 126 | +4. Passage search adds colored rings to matching nodes |
| 127 | +5. Double-click a document to view it with highlighted passages |
| 128 | + |
| 129 | +## Tips |
| 130 | + |
| 131 | +- **Name queries descriptively** — "Governance + Compliance minus Legacy" is better than "Query 1" |
| 132 | +- **Start broad, then subtract** — it's easier to remove noise than to find everything piecemeal |
| 133 | +- **Use the Cypher editor to inspect** — seeing the statements helps understand what an exploration actually does |
| 134 | +- **Cross-explorer replay is instant** — saved queries don't re-fetch from the API, they replay the recorded operations |
| 135 | + |
| 136 | +## Next Steps |
| 137 | + |
| 138 | +- [Exploring Knowledge](exploring.md) — General search and navigation |
| 139 | +- [Querying](querying.md) — CLI, API, and MCP query access |
| 140 | +- [Polarity Axis Analysis](POLARITY_AXIS_ANALYSIS.md) — Semantic dimension analysis |
0 commit comments