You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here is a dataview query that I have been working on to help me manage my notes better in Obsidian. The goal of this query is to list files together in a table based on their similar tags and links, as files with similar tags and links are likely to be part of the same project. The idea is to use clustering of the tags, backlinks, forward links, and other metadata to determine if files are in the same project.
TABLE
file.link as "Note",
file.tags as "Tags",
file.mtime as "Last Modified",
file.status as "Status"
FROM ""
GROUP BY (file.tags + file.backlinks + file.forwardlinks) AS Similar
SORT
Similar,
file.mtime desc,
file.status asc
This query takes advantage of the GROUP BY clause to group files together based on their similar tags and links. It also sorts the files by the last modified date and status. I am hoping this query will help me better organize my notes and make it easier to find related files when working on a project. however, it does not get the clustering I want, and gets mad if any of the backlinks or forwardlinks are null (empty array).
I then tried to use some of my JavaScript knowledge, but I'm failing here and think I am over complicating my clustering process.
// Define a function to calculate the similarity between two sets of tags, backlinks, and forwardlinks
function similarity(set1, set2) {
const intersection = set1.filter(value => set2.includes(value));
const union = [...new Set([...set1, ...set2])];
return intersection.length / union.length;
}
// Get all the files
const files = dv.pages('');
// Group files based on similarity
const groups = new Map();
for (const file of files) {
const {tags, backlinks, forwardlinks} = file;
let found = false;
for (const group of groups.keys()) {
const similarityScore = similarity(
[...tags, ...backlinks, ...forwardlinks],
group
);
if (similarityScore >= 0.7) {
groups.get(group).push(file);
found = true;
break;
}
}
if (!found) {
groups.set([...tags, ...backlinks, ...forwardlinks], [file]);
}
}
// Convert the groups to a list of rows for the Dataview table
const rows = [];
for (const [group, files] of groups) {
for (const file of files) {
rows.push({
Note: file.link,
Tags: file.tags.join(', '),
'Last Modified': file.mtime,
Status: file.status,
Similar: group.join(', '),
});
}
}
rows;
TABLE
Note,
Tags,
'Last Modified',
Status,
Similar
FROM ''
SORT Similar, 'Last Modified' DESC, Status ASC
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Here is a dataview query that I have been working on to help me manage my notes better in Obsidian. The goal of this query is to list files together in a table based on their similar tags and links, as files with similar tags and links are likely to be part of the same project. The idea is to use clustering of the tags, backlinks, forward links, and other metadata to determine if files are in the same project.
This query takes advantage of the GROUP BY clause to group files together based on their similar tags and links. It also sorts the files by the last modified date and status. I am hoping this query will help me better organize my notes and make it easier to find related files when working on a project. however, it does not get the clustering I want, and gets mad if any of the backlinks or forwardlinks are null (empty array).
I then tried to use some of my JavaScript knowledge, but I'm failing here and think I am over complicating my clustering process.
Beta Was this translation helpful? Give feedback.
All reactions