How do I combine 2 index data in elasticsearch?

How do I combine 2 index data in elasticsearch?

Example;

1.index data = {appId,name,clasId}
2.index data={clasId,name,description}

1.index via clasId 2.index class name how do I pull ?

See [Resolved]Join data cross two index based on common field

this page not working
https://www.elastic.co/elasticon/2015/sf/building-entity-centric-indexes

I could not see the solution.

This one? How to merge two indexes based on common field in Elasticsearch? - #3 by Mark_Harwood

How to merge two indexes based on common field in Elasticsearch?

screen shot of the solution here

I do not fully understand the solution.

If that's the solution, I don't understand it.
Can you tell in more detail

It requires writing custom code that uses those APIs.
The exact solution would depend on your preferred choice of programming language.

Can't this process be done in elasticsearch?

It requires writing custom code that uses those APIs.
is there any code snippet that does the operation you mentioned above?

This is a rough outline for merging 2 indices into a third using python https://gist.github.com/markharwood/7bca8a15a6b0c36b6b412971ee192037

POST test1/_doc/1
{
"Id":1,
"name":"fooName",
"categoryId":1
}
POST category/_doc/1
{
"Id":1,
"name":"one",
"address":"fooAddress"
}

here is categoryId into test1,Id into category ,this fields join data, both two field musn't categoryId,

JOİN FİELDS:

test1 :categoryId
category:Id

RESULT:
test1 or other creating third index
{
"Id":1,
"name":"fooName",
"categoryId":1,
"name":"one"
}

If you don't have a common field name you would need to use a script to retrieve the sort value depending on which index the document came from eg.

GET test1,test2/_search
{
  "sort":{
	"_script" : {
			"type" : "string",
			"script" : {
				"lang": "painless",
				"source": "if (doc.containsKey('catId')) return doc['catId']; return doc['myId'] ;"
			},
			"order" : "asc"
		}
  }
}

You'd have to modify my Python code which fuses the documents accordingly because that assumes a common field name.

Can you make join code running in elastic search?

that's exactly what I want.

At some point the database ends and your application code begins.
I’ve already given you the pointers required to do this - if you can’t code that’s fine but we are not here to do that for you.

1 Like

thank you for everything ,
For the first time I have been dealing with nosql structure.

My purpose was this.
In elasticsearch, solve this with a code structure that does this.

I would really appreciate it if you really help.