Garulf / Obsidian-Notes

Search Obsidian notes
43 stars 4 forks source link

Order of the search results seems to be wrong / suboptimal #22

Open Nelvin opened 1 year ago

Nelvin commented 1 year ago

Hi, could you explain the sorting of the search results as I have cases where even the exact written filename of a note doesn't end in the first, and so autocomplete, spot of the results (see the screenshot). In this case it's only on position 3 and the first listed is completely irrelevant to my search, neither the file/notes name nor the actual content includes what I searched for. Thanks

image

Garulf commented 1 year ago

I believe I have a way to fix this. I'll try and get to this when I can.

Thank you for using my plugin.

Nelvin commented 1 year ago

Hi Garulf, just wanted to give the plugin another try and had a look at the source myself as I'd be fine to do small fixes / adjustments on my own. After trying to fiddle around with the scoring I wanted to see the actual numbers and modified the title string of the notes to include the calculated match scores (when calling add_item in the query method in main.py).

What I expected was the identical order of results with just some numbers added to the title text. What I got was a completely different order of results.

You can check this by just modifying the Line. title=note.title, into title=note.title + f"{score} {title_score}", This confused my as I expected the sort order is based on the score value which I didn't touch at all.

Would be great if you could try this on your side and tell me what I may be missing wrt the score/sorting of the results.

Garulf commented 1 year ago

Python plugins do not have access to Flows scoring functions.

I experimented with fuzzy matching in other plugins but found results to be subpar. The Obsidian plugin doesn't use any scoring but simple shows any item that contains your search query.

Eventually I was able to port Flows search algorithm to Python however I have not had a chance to add it to this plugin yet.

With Flows plugin version 2 almost ready it might be better to wait so that it can use the search algorithm directly from Flow.

Nelvin commented 1 year ago

I see - explains why little hacks I tried to tweak scoring just to understand the resulting sorting didn't make any sense :) Looking forward to version 2 then.

Thanks for your answer

AlanEdd commented 3 months ago

Hey there - just checking in to see if this was ever adjusted or fixed. It seemed to be perfect on install but it doesn't seem to update or reindex properly?

image

The workaround or expected behaviour by using the normal Explorer search within the Obsidian vault: image

Thanks!

Garulf commented 3 months ago

Hi @AlanEdd,

Currently the plugin simple matches by filename. Would matching by path be useful?

AlanEdd commented 3 months ago

Well I am not sure how it matches but the exact file name above: "ae tips" puts result in 11th place "ae ToDo" is in first place?

When I add another word "ae tips new" The file moves to the top. So I think it's just the fuzzy search settings. I won't pretend to understand! but searching by "notes\ md " in normal Flow search works better for me for now. Thanks.