Dataview -> extract only matched Line from Page

After the great @holroy focus in tasks, I use lists (same for tasks) as examples of a sub-structure data. Saying it another way: a way to explore metadata in a sub-structure nested in main page metadata structure.


Example note


#work 

## work topics

- (topic:: meeting) Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer aliquet eu nibh sed pharetra. (date:: 2022-11-05)
- Aenean eu magna vel nulla vulputate faucibus.
- Donec at interdum mi, a scelerisque lorem. (topic:: client) Ut laoreet turpis enim, nec elementum augue commodo vitae.
- (topic:: meeting) Suspendisse orci augue, ullamcorper eu enim id, sollicitudin tristique risus (date:: 2022-11-07)


Exploring queries

Now, as first query, explore the field topic as a field at level page:

TABLE topic, file.lists.text
FROM #work 
WHERE contains(topic, "meeting")

As you can see, topic is a key at page level. At this level, filter the topic means filter the page where the field exists.

Now, let’s explore the field topic as also a metadata nested in the file.lists level. For that we need to flatten the array file.lists and add the name Lists to the produced objects.
After that we can explore metadata inside each object.

Fo example, create a table with the text of lists only with the topic meeting (observe that now we add the prefix Lists - the name used before - to each inline field inside the list text):

TABLE Lists.text
FROM #work 
WHERE file.lists
FLATTEN file.lists AS Lists
WHERE Lists.topic = "meeting"

Or filter the previous results with a specific date:

TABLE Lists.text
FROM #work 
WHERE file.lists
FLATTEN file.lists AS Lists
WHERE Lists.topic = "meeting"
WHERE Lists.date = date("2022-11-07")

Results

5 Likes