elasticstore icon indicating copy to clipboard operation
elasticstore copied to clipboard

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

Open teebu opened this issue 5 years ago • 3 comments

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

the update and index call requires a route field

teebu avatar Jul 09 '20 18:07 teebu

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 avatar Jul 12 '20 01:07 teebu

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

teebu avatar Jul 12 '20 03:07 teebu

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

acupofjose avatar Jul 12 '20 20:07 acupofjose