rwynn / monstache

a go daemon that syncs MongoDB to Elasticsearch in realtime. you know, for search.
https://rwynn.github.io/monstache-site/
MIT License
1.29k stars 182 forks source link

[[relate]] not working in monstache #732

Open MihirSavjani opened 2 months ago

MihirSavjani commented 2 months ago

Hii, I'm trying to implement the [[relate]] feature in my project, but I'm not getting the expected output.

Here's the setup:

Database: test with two collections:

  1. users
    {
     "_id": "12345",
     "name": "demo"
    }
  2. orders
    {
     "_id": "456",
     "userId": "12345",
     "productName": "laptop"
    }

I want to include the name from the users collection in the orders records, based on the userId. Here's the configuration in my Monstache config file:

mongo-url = "mongodb://127.0.0.1:27018/test"
elasticsearch-urls = ["http://localhost:9300"]
change-stream-namespaces = ["test.users","test.orders"]
direct-read-namespaces = ["test.users","test.orders"]
enable-http-server = true
verbose = true

[[relate]]
namespace = "test.orders"
with-namespace = "test.users"
src-field = "userId"
match-field = "_id"
keep-src = true
dot-notation = true

I'm using Monstache version 6.7.17 and Elasticsearch version 7.10.0.

After syncing, this is the data I receive in Elasticsearch:

{
  "productName": "laptop",
  "userId": "12345"
}

It seems like the userName is not being added. Could you please help me figure out what might be going wrong?

Thank you in advance!