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

Full-text search query #102

Open
Tracked by #10
srid opened this issue Jul 4, 2021 · 7 comments
Open
Tracked by #10

Full-text search query #102

srid opened this issue Jul 4, 2021 · 7 comments
Labels
enhancement New feature or request

Comments

@srid
Copy link
Owner

srid commented Jul 4, 2021

Now that we have #324, enable access to it from the query feature. The following,

```query
some text
```

... should list all notes containing 'some text'. Inspired by Obsidian.

See #48 (reply in thread)

We could piggyback on #338 to implement this.

@srid srid added the enhancement New feature or request label Jul 4, 2021
@srid srid mentioned this issue Jul 4, 2021
7 tasks
@srid
Copy link
Owner Author

srid commented May 30, 2022

Not having full-text search (including client-side search) is a dealbreaker for some projects, eg: hercules-ci/flake-parts#31 (comment)

@applejag
Copy link
Contributor

Adding stork, as suggested in #242 (comment), was surprisingly easy. Made a proof-of-concept just to play around, and it works super well :)

image

Client-side of this is easy. The hard part of course it to get Haskell to talk the same language and make use of the search results during emanote gen and emanote run time.

Porting Stork to Haskell isn't realistic. However their CLI seems capable enough.

Stork always rebuild the index from scratch, which is bad for bigger sites. However just to get a perspective, here's some quick benchmarks:

Site Indexed files Search terms stork build time
https://emanote.srid.ca/ 30 5,597 ~0.1s
https://input-output-hk.github.io/adrestia/ 94 35,721 ~0.8 to 1s
https://chenghaomou.github.io/ 405 56,762 ~2s

The index-building times are really good, even for the bigger repos.

And if you lock in to the idea of using Stork, then adding at least statically-built search results is a great start, and would deserve a separate ticket.

My idea of how search support would be added to Emanote:

  • Search support becomes opt-in.
  • To enable full-text search in ```query``` and web browser, user must have the stork CLI installed when building the HTML, leaving stork as an optional external integration.
  • On every page update (when using emanote run), Emanote runs stork build to rebuild the index.
  • When building the static site (via emanote gen), Emanote runs stork build at the end.
  • To evaluate ```query``` results, Emanote runs stork search on the prebuilt index file.

Sending pages to Stork during emanote run could be done by generating a big temporary TOML file with the content embedded in it, instead of having to sync the files to .html files all of the time, as emanote run keeps it all in memory (if I understand it correctly).

Other ideas:

  • Access Stork's parsing and searching algos via FFI? ("I'm feeling lucky" Google results) Would require to also add Rust compiler to Emanote's toolchain though, which would slow down build times and could be quite clumpsy.

These are just my two cents. What are your thoughts, @srid ? Maybe this was your plan all along?

@srid
Copy link
Owner Author

srid commented Jul 29, 2022

And if you lock in to the idea of using Stork, then adding at least statically-built search results is a great start, and would deserve a separate ticket.

I agree, and this is what we should do first (without worrying about the query stuff).

Adding stork, as suggested in #242 (comment), was surprisingly easy.

Could you share how you did this? I imagine we can make emanote gen do it automatically.

By the way, the which library can be used to include stork as part of Emanote install.

@srid
Copy link
Owner Author

srid commented Jul 29, 2022

Separate ticket opened: #324

Let's continue the discussion there.

@applejag
Copy link
Contributor

Could you share how you did this? I imagine we can make emanote gen do it automatically.

Yea sure:

@srid
Copy link
Owner Author

srid commented Aug 21, 2022

We have client-side full text search now, but to integrate it with the query feature we will need #338

@applejag
Copy link
Contributor

We have client-side full text search now, but to integrate it with the query feature we will need #338

Using stork search -i stork.st -q "query goes here" CLI would suffice, and would probably be much easier to implement.

Using FFI could improve performance as it would skip translating back and forth between JSON, so suggest keeping it as a possible future enhancement. But the low-hanging fruit is just to use the CLI as you are when building the index.

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