Skip to content
This repository has been archived by the owner on Feb 14, 2023. It is now read-only.

[feature request] parent-join, would need routing, parent/child, joins #31

Open
teebu opened this issue Jul 9, 2020 · 3 comments
Open

Comments

@teebu
Copy link

teebu commented Jul 9, 2020

https://www.elastic.co/guide/en/elasticsearch/reference/current/parent-join.html#

the update and index call requires a route field

@teebu
Copy link
Author

teebu commented Jul 12, 2020

This is the idea, but it's not working properly.

refferences

mappings: {
      '@timestamp': { type: "date" },
      // parent/child
      document_join: {
        type: 'join',
        eager_global_ordinals: true,
        relations: {
          'document': [
            'page'
          ]
        }
      },

    transform: (data, parent) => ({
      ...data,
      '@timestamp': new Date().toISOString(),
      doc_type: 'page',
      document_join: { // join
        name: 'page', 
        parent: data.document_id
      },
    }),

In the private handleAdded = async

try {
      const exists = await Queuer.process(this.client.exists.bind(this, { id: doc.id, index }))
      if (exists.body) {
        // retryOnConflict added in reference to https://github.com/acupofjose/elasticstore/issues/2
        await Queuer.process(
          this.client.update.bind(this, {
            id: doc.id,
            index,
            routing: body.document_join && body.document_join.parent || doc.id, //todo: is body.document_join there?
            body: { doc: body, doc_as_upsert: true },
            retry_on_conflict: 2,
          })
        )

But for some reason the routing isn't working.

@teebu
Copy link
Author

teebu commented Jul 12, 2020

I figured it out. I was missing routing on one of the functions... await Queuer.process(this.client.index.bind

@acupofjose
Copy link
Owner

@teebu feel free to submit a pull request with your implementation!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants