EINDEX / logseq-copilot

Logseq Copilot is a Browser extension that allows you to access your Logseq via your browser.
https://logseq-copilot.eindex.me
GNU General Public License v3.0
235 stars 21 forks source link

Is it possible to add a fuzzy search function? #49

Closed BongeZagh closed 5 months ago

BongeZagh commented 6 months ago

Is your feature request related to a problem? Please describe. I found this plugin to be very helpful when I started collecting data from various websites. However, I encountered a problem when trying to take notes for a specific website. The plugin only matches the note with the exact URL, whereas I would like it to detect any notes I wrote on a certain URL.

Describe the solution you'd like My suggestion would be to add a fuzzy search option that can be turned on whenever needed.

Describe alternatives you've considered If it's not the priority, do you mind telling me which file can change the search mode? I can try to see if I can add this function.

EINDEX commented 6 months ago

Currently, I send the URL without the hash part to logseq to make this recall function.

If you want to extend this function, I suggest just sending one request to logseq and recalling everything you need. Otherwise, logseq needs to process a lot of requests in a short time.

And, there are 2 parts of code related to the recall function.

One is for popup searching: https://github.com/EINDEX/logseq-copilot/blob/32e0a04e62b36a206b0e829d2e9965b91dacca5a/src/pages/popup/Popup.tsx#L44-L59

Another is for badge count number: https://github.com/EINDEX/logseq-copilot/blob/32e0a04e62b36a206b0e829d2e9965b91dacca5a/src/pages/background/index.ts#L103-L109

EINDEX commented 6 months ago

And before putting effort into the development work.

I want to know the rules or patterns. what will be in the search result, and what should be excluded.

Could you give an example of fuzzy searching?

BongeZagh commented 6 months ago

Hi EINDEX, thank you for your reply!

Since I primarily use chatGPT for programming, I will do my best to describe it.

Here are two sample websites: 14:42 [[quick capture]]: About us - Wiren Board I removed the hash part it seems copilot can't search notes on my side 14:40 [[quick capture]]: Technologies, equipment and materials for electronic manufacturing sector

My thought will be no matter which page of the site we click, the plugin can always detect my notes under the website. Then we don't have to read the website again.

I gave my question to ChatGPT this is what I got, I have not idea how to test it yet 😂

  useEffect(() => {
    if (isLoading) return;

    new Promise(async () => {
      console.log('loading');
      let queryOptions = { active: true, lastFocusedWindow: true };
      let [tab] = await Browser.tabs.query(queryOptions);
      setIsLoading(true);
      if (!tab.url) return;
      const url = removeUrlHash(tab.url);

      // Format URL to match wildcard
      const formattedUrl = url.replace(/\/.+/, ''); // Matching and removing everything after the last slash using a regular expression

      // Format URL to match regular expression
      const regexFormat = `^${formattedUrl.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&')}`; // Escaping special characters

      const result = await client.blockSearch(regexFormat);
      if (result.status !== 200) return;
      setLogseqSearchResult(result.response!);
      mountOpenPageMethod();
    });
  });
EINDEX commented 6 months ago

Oh, Maybe I got your idea, you want to have all the notes related to one website.

For example:

When I am on the https://wirenboard.com/en/pages/about/ page. I can see the note for the https://wirenboard.com/en/catalog/kontrollery/ page.

Is that right?

BongeZagh commented 6 months ago

Yes!! You understand it correctly.

EINDEX commented 5 months ago

released in 1.13.0, it will be available at edge & chrome store soon.

BongeZagh commented 5 months ago

That was Awesome!! Thanks a lot!!!!!🥳