- How can I find nodes based on a field value of an ancestor?Sep 26, 2024
There is no way to build a search that is able to read the fields of an ancestor node. But, using title expressions, you can grab the field value of an ancestor node and have it part of the title of the node you're running the search on, making that information searchable.
TLDR: Use the
${sys:owner}
title expression to pick up content from ancestor nodes and their fields.This solution is great for Readwise users and came about when Maggie from the community wanted to search her Readwise highlights by the tags of the article/book it was taken from.
To do this, use
${sys:owner.Field}
, and repeatsys:owner
as many levels up as you need to go to target the right ancestor. In the case of Readwise highlights, you usually need to go up two levels. Check out the demo video:Now with the information you need from the ancestor node baked into the title of the highlight itself, it can be used to search and filter those nodes.
While this solution came up in the context of the Readwise integration, it is a reusable pattern that can be applied elsewhere.
Readwise integration
Overview
Readwise integration with Tana is available for those with a Readwise subscription or if you started their free trial which allows for export of 10 most recently highlighted documents.
For more on what Readwise is, check out their webpage: https://readwise.io/
Documentation
Before you begin, you must read the following important information about this integration:
Setup
Step 1: Connect Readwise to Tana
Log into your Readwise account and go into Tana as Export option or head over to this page for the Tana Export settings: https://readwise.io/export/tana/preferences
It will prompt you to create a Tana API and to paste it into Readwise. Do this by going to your Settings > API tokens, then pick the workspace you want them synced to, and hit Create.
A token is immediately created and copied to your clipboard. Head back to Readwise and plug that into the setup and hit Save.
Step 2: Review the Export settings
This is an overview of all the options available on the Tana Export page:
- Button to initiate an export: Press to initiate sync. NOTE: You'll likely want to tweak some of the settings before exporting all your highlights at the same time, so we do not recommend pressing this until you've reviewed at least all of Step 3.
- Export Automatically (when new highlights are added): Turn this on to have Readwise automatically push new highlights to Tana as they're made. We advise to wait with turning this on until you are satisfied with the export from Readwise.
- Use Compact Layout (Merge multi-lines highlights in one-line, disabling will split lines in multiple nodes.): Tana doesn't support soft line-breaks in nodes, so this gives you the option to either have highlights with soft line-breaks exported as separate nodes, or to have the line-breaks removed which keeps the highlight as one node.
- Send documents to Inbox (It will send documents to Inbox instead of your Library): New documents and highlights are by default sent to a special Readwise node created in the Library. Turn this on to instead have these forwarded to your Inbox instead. NOTE: Inbox is not recommended for first imports if you have hundreds of documents/highlights in Readwise.
- Use Custom Formatting (Customize the format of your Tana page using Readwise templates): Turn this on to customize how content is exported. Readwise has a highly customizable template language that you can use to change how your documents and highlights are exported.
- 5A. Page title: This will determine the format of the Document node
- 5B. Highlight: This formats the Highlights
- 5C. Page fields: This determines the names of the fields. You can turn them on or off.
- Select items to be Exported (Filter which books/articles/tweets to sync to Tana): Turn this on to select which documents you want to export (6A).
Step 3: How to fine tune your export until it's perfect
We know Tanarians care a lot about how incoming information is structured when it comes from elsewhere! Below are instructions on how to responsibly tweak your export settings without making a huge mess in the process that will need a lot of cleanup.
1. When fine tuning your settings, turn on the following settings, and the rest keep off:
2. For your first export, pick a few documents to export at the time to see what they look like in Tana: Pick ones with many different features used, like document tags and notes, highlight tags and notes and images, books and videos, etc. so you're testing every possibility you're likely to see in your highlights.
4. Find the exported node and take a look: Look in Library, or try to @-mention a node called "Readwise". Reminder that upon initial export, Readwise will create supertags and fields in your workspace, saving them in the Schema. From this initial export, you may want to change some things in the export settings, and try again. Hard-delete (Cmd/Ctrl+Shift+Backspace) the document nodes in Tana before re-exporting. Do NOT delete the main Readwise node.
5. Tweak export settings: Make adjustments in Readwise based on what you saw.
6. To make a fresh export of a document after making adjustments: You must tell Readwise to "refresh" a document which will reset Readwise's memory of having synced that particular document before. (This essentially makes Readwise forget the nodeID associated with this document)
7. Repeat steps 3 to 6 until you're happy!
8. Once you're satisfied, feel free to turn "Export Automatically" ON and "Select items to be exported" OFF. This will make Readwise sync everything in the next sync cycle, and every other document and highlight that gets added thereafter. If you have many highlights, this may take some time and occasionally freeze Tana. The work happens in the background, so it's safe to close it or leave it open while it's doing a big sync.
Step 4: Once it's in Tana
Properly making the supertags: You can promote the fields to the supertags, rearrange them anyway you see fit, pick a colour, and even add fields of your own.
Ideas for surfacing your Readwise content: By default, Readwise will sync to a special Readwise node in the Library. Below is some inspiration on how you can surface this content:
- To see your whole Readwise Library:
- Make a Reference to the Readwise node somewhere prominent or memorable
- Pin the Readwise node
- To see parts of your library:
- To see your highlights by the day they were synced
- Highlight tag
- Created on day node: parent
- To see your latest documents from the past 30 days:
- Readwise tag
- edited last 30 day
- To see your highlights by the day they were synced
Advanced considerations, or if you have existing Readwise content in your workspace
If you have previous imports to Tana from Readwise, either through Reader Export via clipboard or other custom implementation from our very inventive community such as Brandon's readwise.toolsfortana, you may be wondering whether to merge your existing information with the new setup, or not.
The following section will be important to read for your considerations.
Readwise does not retrieve any information from your workspace, other than the nodes, tags and fields that it creates and saves the nodeID from. For the first iteration of this integration we've decided to only permit Write permissions and limit Read permissions. From a security perspective it's good because it means that Readwise has no access to your workspace content other than the nodes it creates. From an automation perspective it may leave a bit to desire because your imports will not automatically link to nodes that exist in your workspace. That said...
Tana AI and commands can fill a lot of last mile connections: A workaround is to use AI to connect plain text with nodes in your graph once the content is there.
It's currently not possible to create multiple nodes inside of a field: This means that a highlight Tag field for instance will export tags as just words in a single node. However, if you use AI in Tana, this info can be extracted (see point above).
Merge direction is super important: When merging your tag/field/node with a Readwise-equivalent object, always merge in the direction of what Readwise had created. This ensures that the Readwise-synced nodeID is preserved so it can send updates to it in the future.
Above is important because deleted nodes still get synced to: If you delete a document node that Readwise creates, Readwise will continue to push changes to it because it looks for a nodeID match, no matter where it is in the graph. See Step 3 on how to properly disassociate document nodes created by Readwise.
For a full reset, make a new API token: Replacing the API token with a new one will prompt a fresh export, no matter what was exported to your workspace in the past. Readwise relinquishes all previous nodeIDs it has saved, and all new tags, fields and nodes will be created. Useful if you want to do something like change which workspace it gets synced to, or start from scratch.