Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Searching for a note ID returns only where it's found if it's linked elsewhere; returns the original note if not #9769

Closed
samcan opened this issue Jan 23, 2024 · 5 comments
Assignees
Labels
bug It's a bug desktop All desktop platforms high High priority issues

Comments

@samcan
Copy link

samcan commented Jan 23, 2024

Operating system

Windows

Joplin version

2.13.4

Desktop version info

Joplin 2.13.4 (prod, win32)

Client ID: f82095b3dd2d47a4952fd95eaa6eaa93
Sync Version: 3
Profile Version: 44
Keychain Supported: No

Revision: 66036c2

Current behaviour

I was tracking down a bug in a backlinks plugin where notes included backlinks to themselves, and believe it's a bug in Joplin, added in 2.13.4. I tested, and this behavior was not present in 2.13.3.

If Note A is linked to by Note B, searching for Note A's ID returns only Note B. If Note A is not linked to by any notes, only Note A is returned in the search results.

To reproduce:

  1. Open Joplin 2.13.4.
  2. Copy the Markdown link for a note (Note A) and paste it into a different note (Note B).
  3. After waiting a bit for the search indexing to complete, search for the Note A's ID. Note B should be the only note returned in the results.
  4. Delete the Markdown link to Note A from Note B.
  5. Wait a bit more for the search indexing to complete, and then search again for Note A's ID. Note A is the only note in the search results.

Expected behaviour

I think the most correct behavior is that searching for Note A's ID should include Note A in the search results, and it shouldn't matter whether any other notes link to it or not.

Then, any backlinks plugins would just need to filter their results to exclude the original note.

Logs

No response

@samcan
Copy link
Author

samcan commented Jan 23, 2024

This behavior is also present in 2.14.10.

@laurent22
Copy link
Owner

Hmm, yes that's exactly what it's supposed to do:

3667bf3#diff-f6b8353a25e91e1bb628d431c4da49a20266f6e5e592e4221d0d230bf9877788R531-R546

It searches by note ID if not other results were found.

We want to be able to type a note ID and have it return that note but I can see how that can be a problem for your plugin.

For now, are you able to just ignore the results where query == note.id? And then we can think of a way to improve this

@laurent22 laurent22 added desktop All desktop platforms high High priority issues labels Jan 23, 2024
@samcan
Copy link
Author

samcan commented Jan 23, 2024

I can look into submitting a pull request for Automatic Backlinks to note: I'm not the developer; just a concerned user who was confused why the plugin had stopped working and wanted to see if I could fix it. A group of us encountered the issue last month, and the working hypothesis was that something was wrong with the plugin (https://discourse.joplinapp.org/t/backlinks-include-note-itself-since-update/34104/7).

That said, per the forum conversation above, there are two plugins that are affected by this, Automatic Backlinks to note, and DDDot, so this fix would have to be made on both plugins.

@laurent22
Copy link
Owner

TODO: for now remove this feature:

It searches by note ID if not other results were found.

Later maybe we can add a filter such as id:xxxx

@laurent22 laurent22 self-assigned this Jan 26, 2024
@JackGruber
Copy link
Contributor

A search filter for id is already implemented.
grafik

it('should support filtering by note id', (async () => {
let rows;
const note1 = await Note.save({ title: 'Note 1', body: 'body' });
const note2 = await Note.save({ title: 'Note 2', body: 'body' });
const note3 = await Note.save({ title: 'Note 3', body: 'body' });
await engine.syncTables();
rows = await engine.search(`id:${note1.id}`, { searchType });
expect(rows.length).toBe(1);
expect(ids(rows)).toContain(note1.id);
rows = await engine.search(`any:1 id:${note1.id} id:${note2.id}`, { searchType });
expect(rows.length).toBe(2);
expect(ids(rows)).toContain(note1.id);
expect(ids(rows)).toContain(note2.id);
rows = await engine.search(`any:0 id:${note1.id} id:${note2.id}`, { searchType });
expect(rows.length).toBe(0);
rows = await engine.search(`-id:${note2.id}`, { searchType });
expect(rows.length).toBe(2);
expect(ids(rows)).toContain(note1.id);
expect(ids(rows)).toContain(note3.id);
}));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug It's a bug desktop All desktop platforms high High priority issues
Projects
None yet
Development

No branches or pull requests

3 participants