News for hackers. Stuff that matters.
Re:Postgres Full-Text Search: A search engine in a database by fizx on Tuesday July 27, 2021 @12:12PM (#27974139)
Hi, I started an Elasticsearch hosting company, since sold, and have built products on PG's search and SQLite FTS search.

There are in my mind two reasons to not use PG's search.

1. Elasticsearch allows you to build sophisticated linguistic and feature scoring pipelines to optimize your search quality. This is not a typical use case in PG.

2. Your primary database is usually your scaling bottleneck even without adding a relatively expensive search workload into the mix. A full-text search tends to be around as expensive as a 5% table scan of the related table. Most DBAs don't like large scan workloads.

Re:Postgres Full-Text Search: A search engine in a database by quietbritishjim on Tuesday July 27, 2021 @12:25PM (#27974290)
Do you see any particular reasons to use or not use ZomboDB [1]? It claims to lets you use ElasticSearch from PG seamlessly e.g. it manages coherency of which results ought to be returned according to the current transaction. (I've never quite ended up needing to use ES but it's always seemed to me I'd be likely to need ZomboDB if I did.)

[1] https://github.com/zombodb/zombodb

Re:Postgres Full-Text Search: A search engine in a database by Conlectus on Tuesday July 27, 2021 @04:30PM (#27977201)
Though I have only a recreational interest in datastores, I would be pretty wary of a service that claims to strap a Consistant-Unavailable database (Postgres) to an Inconsistent-Available database (ElasticSearch) in a useful way.

Doing so would require ElasticSearch to reach consensus on every read/write, which would remove most of the point of a distributed cluster. Despite this, ZomboDB's documentation says "complex aggregate queries can be answered in parallel across your ElasticSearch cluster".

They also claim that transactions will abort if ElasticSearch runs into network trouble, but the ElasticSearch documentation notes that writes during network partitions don't wait for confirmation of success[1], so I'm not sure how they would be able to detect that.

In short: I'll wait for the Jepsen analysis.

[1] https://www.elastic.co/blog/tracking-in-sync-shard-copies#:~...

Re:Postgres Full-Text Search: A search engine in a database by zombodb on Tuesday July 27, 2021 @06:14PM (#27978334)
> Doing so would require ElasticSearch to reach consensus on every read/write

ZomboDB only requires that ES have a view of its index that's consistent with the active Postgres transaction snapshot. ZDB handles this by ensuring that the ES index is fully refreshed after writes.

This doesn't necessarily make ZDB great for high-update loads, but that's not ZDB's target usage.

> They also claim that transactions will abort if ElasticSearch runs into network trouble...

I had to search my own repo to see where I make this claim. I don't. I do note that network failures between PG & ES will cause the active Postgres xact to abort. On top of that, any error that ES is capable of reporting back to the client will cause the PG xact to abort -- ensuring consistency between the two.

Because the ES index is properly refreshed as it relates to the active Postgres transaction, all of ES' aggregate search functions are capable of providing proper MVCC-correct results, using the parallelism provided by the ES cluster.

I don't have the time to detail everything that ZDB does to project Postgres xact snapshots on top of ES, but the above two points are the easy ones to solve.

Re:Postgres Full-Text Search: A search engine in a database by mrslave on Tuesday July 27, 2021 @07:54PM (#27978979)
ZomboDB scratches an itch in a way I find fascinating, though I have yet to do more with it than shoehorn it into a prototype that was a bit square-peg-in-a-round-hole. It is in my catalogue of technologies I hope exploit someday. And I hope you're enjoying the work and making some $$$ too.

While I'm here might I ask, are you finding the hosted PostgreSQL services (AWS, Azure, etc.) growing or shrinking your market opportunities? Also, does it play nice with Citus?

Re:Postgres Full-Text Search: A search engine in a database by zombodb on Tuesday July 27, 2021 @09:07PM (#27979354)
I don’t pay any attention to what the cloud providers are doing. I have no control over them so….. eh.

ZDB is still alive and well but I have a real job now too.

Re:Postgres Full-Text Search: A search engine in a database by Conlectus on Tuesday July 27, 2021 @08:11PM (#27979072)
I suppose I must have misinterpreted this line

> As such, any sort of failure either with ZomboDB itself, between Postgres and Elasticsearch (network layer), or within Elasticsearch will cause the operating Postgres transaction to ABORT. [1]

In my defense, there is a fairly important distinction between "any error that ES is capable of reporting back" and "any sort of failure within Elasticsearch".

That said, I and trust that you're more familiar with consistency levels than me, so I'll bow out here.

[1] https://www.zombodb.com/documentation/things-to-know/

Re:Postgres Full-Text Search: A search engine in a database by zombodb on Tuesday July 27, 2021 @08:30PM (#27979184)
I can definitely reword that if it's confusing.
Re:Postgres Full-Text Search: A search engine in a database by mixmastamyk on Tuesday July 27, 2021 @12:58PM (#27974693)
You can do anything, anything at all, at https://zombo.com/

"The only limit, is yourself…"

Re:Postgres Full-Text Search: A search engine in a database by habibur on Tuesday July 27, 2021 @01:27PM (#27975067)
It's still around?
Re:Postgres Full-Text Search: A search engine in a database by mumblemumble on Tuesday July 27, 2021 @02:25PM (#27975747)
That seems like one for the philosophers. If you completely rewrite a Flash site in HTML5, but it looks the same and has the same URL, is it still the same site?
Re:Postgres Full-Text Search: A search engine in a database by da_chicken on Tuesday July 27, 2021 @04:16PM (#27977061)
So, YouTube?
Re:Postgres Full-Text Search: A search engine in a database by mixmastamyk on Tuesday July 27, 2021 @01:46PM (#27975324)
Klicken-Sie Link.
Re:Postgres Full-Text Search: A search engine in a database by FpUser on Tuesday July 27, 2021 @03:28PM (#27976502)
This one is my favorite for many many years. Good for relaxing.
Re:Postgres Full-Text Search: A search engine in a database by NortySpock on Tuesday July 27, 2021 @12:25PM (#27974293)
Regarding point 2: Shouldn't you be moving your search queries from your transaction server to a separate analysis or read-replica server? OLTP copies to OLAP and suddenly you've separated these two problems.
Re:Postgres Full-Text Search: A search engine in a database by blowski on Tuesday July 27, 2021 @01:03PM (#27974753)
…and created a new one if the projection is only eventually consistent. No free lunches here.
Re:Postgres Full-Text Search: A search engine in a database by zepolen on Tuesday July 27, 2021 @01:14PM (#27974898)
How is that different from running Postgres and Elasticsearch separately?
Re:Postgres Full-Text Search: A search engine in a database by blowski on Tuesday July 27, 2021 @01:23PM (#27975022)
It’s not.

It’s a difference between having separate OLAP and OLTP databases, which is what the parent post suggested.

Re:Postgres Full-Text Search: A search engine in a database by justinclift on Tuesday July 27, 2021 @01:31PM (#27975128)
Probably skill set of staff?

For example, if a place has developed fairly good knowledge of PG already, they can "just" (!) continue developing their PG knowledge.

Adding ES into the mix though, introduces a whole new thing that needs to be learned, optimised, etc.

Re:Postgres Full-Text Search: A search engine in a database by kurko on Tuesday July 27, 2021 @02:02PM (#27975506)
I agree with reason 1, but reason 2 is an answer for, "should I use PG search in the same PG instance I already have", and that's a different discussion. You can set up a replica for that.
Re:Postgres Full-Text Search: A search engine in a database by pmarreck on Tuesday July 27, 2021 @02:36PM (#27975873)
> sophisticated linguistic and feature scoring pipelines to optimize your search quality

You CAN score results using setweight, although it's likely not as sophisticated as Elasticsearch's

https://www.postgresql.org/docs/9.1/textsearch-controls.html

Disclaimer: I use Postgres fulltext search in production, very happy with it although maintaining the various triggers and stored procs it requires to work becomes cumbersome whenever you have to write a migration that alters any of them (or that in fact touches any related field, as you may be required to drop and recreate all of the parts in order not to violate referential integrity)

It is certainly nice having not to worry about 1 additional dependency when deploying, though

Re:Postgres Full-Text Search: A search engine in a database by busymom0 on Tuesday July 27, 2021 @09:47PM (#27979569)
Regarding point 2, my implementation was to have a duplicate database server where all the search queries are sent. This would ensure that the search wouldn't slow down the main database. And most of the duplication would happen quick enough so that the search results were almost up to date.