Open batamar opened 4 years ago
Hi @batamar,
When you route events outside the defaults you currently have 2 ways to help monstache handle deletes.
If you have a simple 1 to 1 mapping between MongoDB collection and Elasticsearch index then you can specify that like...
[[mapping]]
namespace = "db1.col1"
index = "singleIndex"
[[mapping]]
namespace = "db2.col1"
index = "singleIndex"
If you have a 1 to many mapping between MongoDB collection and Elasticsearch index then you can solve that like ...
routing-namespaces = [ "db1.col1", "db2.col1" ]
This causes a search in Elasticsearch to find the document and delete it when a delete occurs on db1.col1
, db2.col1
, etc.
In either case, you currently need to know and specify all the MongoDB namespaces up front.
If you need something more dynamic you would need to use a golang
plugin and implement the Process
function. This lets you handle complex use cases.
Just thought I would add, and you may already be aware of this, but Elasticsearch is flexible in it's ability to search multiple indices at once, as an alternative to collapsing many collections to one index.
Not sure if this is acceptable in your case, but you can search for a wildcard index like erxes_*.customers
and that would search across all the customers across all orgs.
Just thought I would add, and you may already be aware of this, but Elasticsearch is flexible in it's ability to search multiple indices at once, as an alternative to collapsing many collections to one index.
Not sure if this is acceptable in your case, but you can search for a wildcard index like
erxes_*.customers
and that would search across all the customers across all orgs.
@rwynn Thank you for the response. First i was indexing to multiple indexes but i have over 4k databases which were leading to maximum shards count exceeds error.
Hi @batamar,
When you route events outside the defaults you currently have 2 ways to help monstache handle deletes.
If you have a simple 1 to 1 mapping between MongoDB collection and Elasticsearch index then you can specify that like...
[[mapping]] namespace = "db1.col1" index = "singleIndex" [[mapping]] namespace = "db2.col1" index = "singleIndex"
If you have a 1 to many mapping between MongoDB collection and Elasticsearch index then you can solve that like ...
routing-namespaces = [ "db1.col1", "db2.col1" ]
This causes a search in Elasticsearch to find the document and delete it when a delete occurs on
db1.col1
,db2.col1
, etc.In either case, you currently need to know and specify all the MongoDB namespaces up front.
If you need something more dynamic you would need to use a
golang
plugin and implement theProcess
function. This lets you handle complex use cases.
@rwynn Thanks.
@rwynn Can I use regex like following
[[mapping]]
namespace-regex = "^erxes_.+.customers$"
index = "singleIndex"
@rwynn Can I use regex like following
[[mapping]] namespace-regex = "^erxes_.+.customers$" index = "singleIndex"
That might be something to consider for the future.
If you need a solution with the existing functionality give this a try:
# on a delete search for document regardless of the original ns in MongoDB
routing-namespaces = [ "" ]
# this is optional but may improve the performance of deletes by scoping the search
delete-index-pattern = "erxes_*"
I have multiple databases like
erxes[organizationId] erxes[organizationId] erxes_[organizationId]
They all have collections named customers, companies. And I am syncing all these databases into single indexes like erxescustomers, erxescompanies with the organizationId fields. When I am creating and updating, sync process is working perfectly. But When i try to delete the documents, it is looking for a wrong index and throwing following error
The main error is
"reason":"no such index [erxes_5efe0a832bcb0ce0bac291cc.customers]"
Here is my toml file. Thanks in advance