Lurker News

Comments (80) 22 threads

Earlier comments
smusamashah1 reply#
It's super uncomfortable when any site uses OR based search. Is there a way to perform AND based search so that when I write more words, the results reduce instead of increasing exponentially?
jabo#
The Typesense search backend supports this, I just haven't added a UI element for it.
mpalmer1 reply#
Can't fault the performance! Nice work. My one UX suggestion would be to present search results in a more table-like layout, as reading both across and down to see every result is not ideal.
jabo#
That’s a good point about reading directions, especially in a list that’s ranked. Thank you for the feedback.
tommoor2 replies#
Seems like this exposes the flaw in the dataset. Eg, searching for "cixin liu" there are many different variations of the same book that show up, lots and lots of duplication.
cldellow#
I think that's a flaw [if you want to call it that] in the presentation of the search results, not the underlying dataset.

If you click through to the OpenLibrary dataset, you can see that the data model understands that the variations are editions of the same underlying text.

jabo#
I iterated through the "editions" dataset to build the index, which contains one record for each book (edition), which is why you see one result for each edition.

There's another dataset called "works" which has one record for all editions of a book, but it didn't have all the data points I wanted. So I decided to keep it simple for a weekend project and use the editions dataset.

interactivecode4 replies#
@jabo is it possible to connect typesense (or any other instance search provider) to a postgresql instance and have it “just work”?
adenta2 replies#
Is such a thing possible? Yes.

Has anybody built it? No :(.
That would totally be the dream though. No reindexing. Pg_search is def fast enough for a large swath of use cases.
What I do is I’ve built a real barebones search controller that connects to Postgres. My controller only lets you search on one attribute, and I use it for autocompletes. Anything more involved, I use typesense.

karterk1 reply#
As I posted in another comment [1], the biggest problem is handling updates and deletes. Requires that you do some kind of logical deletion with an `last_updated_at` timestamp to fetch updates from a primary table.

[1] https://news.ycombinator.com/item?id=25417856

adenta2 replies#
I don't quite follow. For a system reliant entirely on Postgres, you can just fetch the records, and join them in real time, no? It would be much slower than elasticsearch, but still _good enough_ for a lot of use cases.

Continue this thread — 2 replies

karterk#
Keeping an external search system in-sync with the primary DB is certainly a pain point. The biggest problem is that the records in the DB will likely be normalized, while the records in a search store will not be.

You can "poll" for new records for indexing by using a query, but handling deletes/updates is the real deal breaker. You will then have to use both the binlog (atleast for mysql) and querying, at which point it becomes quite complicated to reason about.

Viruptc#
For our setup with Typesense we created a mapping, did an initial bulk import and then set up ORM lifecycle events to sync insert/delete/updates from the database to Typesense. We are using Symfony with Doctrine as the ORM.
jabo#
The challenge is that there are several ways of doing this depending on your larger architecture. So the definition of "just work" depends on the context of your particular architecture.

For eg: you could hook into your ORM and send change events to Typesense like another commenter pointed out; if you have an event bus, you could hook into those messages and push to Typesense from a listener; you could use something like Maxwell to get a JSON stream from the DB binlogs and write the data you need into Typesense; or you could write a batch script which runs a set of SQL queries on a schedule and batch export + import into Typesense.
Also, typically you'd want to curate the fields that you put in a search index, vs what you store in your transactional database, so there is some level of data transformation that's needed anyway.
So long story short, it depends on your architecture!

Load more comments