If you're planning bidirectional, then stop for a while, because only sync via database is not enought. That's why I ask you is you got some java skills. We have been thinking a lot about replication actually we've solved clustering configuration ( on same intranet ) and mirror master-slave, but the case master-master althought is thinked is not implemented ( or solved )
There're several problem with this kind of synchronization I will try to give you some minimal example:
Upload file from api -> execute internal process which call lucene indexer and then the file is indexed. But if you make this change only in databaes level ( not calling api, the application never will know that this file should be indexed ). The problem you'll got is that files uploaded in master A will be searchable in scenario A but not in B and the same with B.
Synchronization can not be done only at database or file ( rsynch level ) althought is a good aproximation ( and valid for master-slave ) is not valid for master-master configuration.
Option 1
Based on the solution you propose, control new files on master A and master B and make a process to index these specific files by lucene. I think with it could be enought, but althought sound easy is not so trivial, because we can go into infinite cycle of updates caused by database update infinite loop ( change in master A needs change in master B to reindex, which generates database change in master B, that fires change in master A. I think can be solved and not come into infinite loop but must be think with care.
Option 2
We have thinked do it by java task based on activity log operation and extending import / export features, and some minimal tables sync ( basically users, roles and other administration but not entire ). The idea is, for example in log appears actions:
1- Created folder XX
2- Created document path YY
3- Renamed
4- Moved
5- Changed grants
Evaluate the sequence and create exports actions wich related files ( similar as export but as a collection of actions to be executed in some order ) and similar as import in same order ( obviously can be colisions, problems etc..., folders that not exists ). This option is based on sync each minutes, each hours or only daily ( that's the idea of this option ), basically not live sync.
Option 3.
Real time sync with webservices ( that can make system more slowly, and I think it not solves the conectivity problem you got ).
Us we have not enought hands - at this moment - for doing option 2 which for us have more interest althought 1 is also interesting. If you're able work on it contact with us with
http://www.openkm.com/en/contact.html indicating the post of the url and we will contact with you directly. I think is an interesting feature ( configuration ) and if you wish to work on it we will try to help you more nearly.