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

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

Closed
BongeZagh opened this issue Dec 15, 2023 · 7 comments
Closed

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

BongeZagh opened this issue Dec 15, 2023 · 7 comments
Labels
enhancement New feature or request

Comments

@BongeZagh
Copy link

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 EINDEX added the enhancement New feature or request label Dec 18, 2023
@EINDEX
Copy link
Owner

EINDEX commented Dec 21, 2023

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:

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);
const result = await client.blockSearch(url);
if (result.status !== 200) return;
setLogseqSearchResult(result.response!);
mountOpenPageMethod();
});
});

Another is for badge count number:

const badgeSearch = async (url: string | undefined, tabId: number) => {
if (!url) return;
const cleanUrl = removeUrlHash(url);
const searchRes = await logseqClient.blockSearch(cleanUrl);
const resultCount = searchRes.count ? searchRes.count!.toString() : '';
await setExtensionBadge(resultCount, tabId);
};

@EINDEX
Copy link
Owner

EINDEX commented Dec 21, 2023

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
Copy link
Author

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
Copy link
Owner

EINDEX commented Dec 24, 2023

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
Copy link
Author

Yes!! You understand it correctly.

@EINDEX
Copy link
Owner

EINDEX commented Jan 7, 2024

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

@EINDEX EINDEX closed this as completed Jan 7, 2024
@BongeZagh
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants