pgsync
pgsync copied to clipboard
How to add WHERE clause to schema?
Sorry if asked before but I couldn't find in examples, documentation or closed issues but how we can add where clause to schema? Say that I'd like to sync only the rows with column status is equal to 100.
This has come up before. Its not easy to come up with a generic user friendly configuration based query language to support this functionality.
Your use case is probably straightforward but to completely support
the WHERE clause is not.
The easiest way is to leverage the plugin functionality. Here is an example and documentation
Thanks for your attention. As far as I understand plugins still fetches the data from postgresql and filter out just before indexing into elasticsearch right? @toluaina
You are right this wasn't so easy. I have made a change to how the plugin works in the master branch. So you can do this now. Here is an example
class MyFilterPlugin(plugin.Plugin):
"""Example Filter plugin."""
name: str = "Filter"
def transform(self, doc: dict, **kwargs) -> dict:
"""Demonstrates how to perform a filter."""
doc_id = kwargs["_id"]
doc_index = kwargs["_index"]
if doc["id"] == 1:
return None
return doc