Index types connection


(Marcin Dojwa) #1

Hi,

I have the following problem:
I have e.g. an index 'documents' and 2 types in it: 'a' (/documents/a)
and 'b' (/documents/b) that look as follows:
a:
{
"internal_id" : 'abs12',
"other_data" : 'data'
}

b:
{
"internal_id" : 'abs12',
"b_data" : 'other data'
}

The question is, how to connect these indexes by "internal_id" so I
could do the _search on /documents/a/_search and get both, documents
from type 'a' and corresponding documents from type 'b' having the
same "internal_id" that the ones from type 'a'. I want to get
something like a LEFT JOIN b ON a.internal_id = b.internal_id in SQL

Thanks for help.


(Clinton Gormley) #2

Hiya

I have the following problem:
I have e.g. an index 'documents' and 2 types in it: 'a' (/documents/a)
and 'b' (/documents/b) that look as follows:
a:
{
"internal_id" : 'abs12',
"other_data" : 'data'
}

b:
{
"internal_id" : 'abs12',
"b_data" : 'other data'
}

The question is, how to connect these indexes by "internal_id" so I
could do the _search on /documents/a/_search and get both, documents
from type 'a' and corresponding documents from type 'b' having the
same "internal_id" that the ones from type 'a'. I want to get
something like a LEFT JOIN b ON a.internal_id = b.internal_id in SQL

You can't do this in a single query, unless you know what internal_id
you want to retrieve before you run the query.

If you do know the internal_id before you start, then you can just
search across multiple types:

/documents/a,b/_search

clint


(Marcin Dojwa) #3

Thanks for the answer.

Best regards.

2012/3/14 Clinton Gormley clint@traveljury.com

Hiya

I have the following problem:
I have e.g. an index 'documents' and 2 types in it: 'a' (/documents/a)
and 'b' (/documents/b) that look as follows:
a:
{
"internal_id" : 'abs12',
"other_data" : 'data'
}

b:
{
"internal_id" : 'abs12',
"b_data" : 'other data'
}

The question is, how to connect these indexes by "internal_id" so I
could do the _search on /documents/a/_search and get both, documents
from type 'a' and corresponding documents from type 'b' having the
same "internal_id" that the ones from type 'a'. I want to get
something like a LEFT JOIN b ON a.internal_id = b.internal_id in SQL

You can't do this in a single query, unless you know what internal_id
you want to retrieve before you run the query.

If you do know the internal_id before you start, then you can just
search across multiple types:

/documents/a,b/_search

clint


(system) #4