monstache icon indicating copy to clipboard operation
monstache copied to clipboard

Record update is not applicable in the relate setting.

Open lineaheshsh opened this issue 4 years ago • 3 comments

hello lewin

We succeeded in joining two collections through the relate setting.

My setup is like this:

mongo-url = "mongodb://127.0.0.1:27020/test"

elasticsearch-urls = ["http://127.0.0.1:9200"] elasticsearch-max-conns = 4 elasticsearch-max-seconds = 5 elasticsearch-max-bytes = 8000000

dropped-collections = false dropped-databases = false

namespace-regex = "^test." direct-read-namespaces = ["test.news_view"] change-stream-namespaces = ["test.news_20210717", "test.news_code_20210717"]

gzip = true stats = true index-stats = true resume = true resume-name = "replica" resume-strategy = 0 verbose = true index-as-update = true

[[mapping]] namespace = "test.news_view" index = "news_view"

[[relate]] namespace = "test.news_20210717" with-namespace = "test.news_view" keep-src = false

[[relate]] namespace = "test.news_code_20210717" with-namespace = "test.news_20210717" src-field = "CATEGORY" match-field="CATEGORY_CODE" keep-src = false

[[script]] namespace = "test.news_view" routing = true script = """ module.exports = function(doc) { var timestamp = new Date(); doc.timestamp = timestamp; doc._meta_monstache = {routing: doc._id, index: "news_view" }; return doc; } """

[logs] info = "logs/info.log" trace = "logs/trace.log" error = "logs/error.log" warn = "logs/warn.log"

The problem is that when the record of the test.news_20210717 collection is updated, it is not applied to the news_view index, but a new index called "test.news_20210717" is created.

How can I set it up so that relate can be applied when updating?

lineaheshsh avatar Jul 17 '21 11:07 lineaheshsh

I found a way.

I found that to use change-stream-namespace with [[relate]], [[mapping]] needs to be additionally set.

Below are the modified settings.

direct-read-namespaces = ["test.news_view"] change-stream-namespaces = ["test.news_20210717", "test.news_code_20210717"]

gzip = true stats = true index-stats = true resume = true resume-name = "replica" resume-strategy = 0 verbose = true index-as-update = true

[[mapping]] namespace = "test.news_20210717" index = "news_view"

[[mapping]] namespace = "test.news_view" index = "news_view"

[[relate]] namespace = "test.news_20210717" with-namespace = "test.news_view" keep-src = false

[[relate]] namespace = "test.news_code_20210717" with-namespace = "test.news_20210717" src-field = "CATEGORY" match-field="CATEGORY_CODE" keep-src = false

lineaheshsh avatar Jul 18 '21 12:07 lineaheshsh

Hi @lineaheshsh, It would be really helpful if you could please have a look at the issue: #602 and give any suggestion to fix it.

BhupenPal avatar Feb 04 '22 08:02 BhupenPal

Hi @BhupenPal

Thank you very much for your interest.

Unfortunately, my current source has changed a lot. Due to performance issues and real-time data issues, we decided not to create View Collections in MongoDB.

Thank you for your advice, I will refer to it when working on a project using View Collection in the future.

Happy New Year!

lineaheshsh avatar Feb 07 '22 23:02 lineaheshsh