Using ids vs natural language

Hey,

For the following situation:

doc-entry
{
"id" : 1,
"users" : [1001, 2002],
}

user-entry
{
"id": 1001,
"name": "a"
},
{
"id": 2002,
"name": "b"
}

Lets say I search for doc-entries that contains user_id= 1001, is it
possible for elasticsearch to automatically map the user id to the user
object and return something like:

doc-entry
{
"id" : 1,
"users" : ["a", "b"]
},

And in this case what happens if you want to search doc-estry using a user
name, could elasticsearch automatically lookup the user id and then search
the name field?

I have a very relation db like way of thinking, what would best practice be
when doing something like this in elasticsearch. Could I solve this by
using natural language as id, e.g. using the user name as id

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/6fb2ff7b-528b-41f9-8a21-e324584785fb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hi,

if you only want to search for doc-entries by user-names, then you could
simply store the user-names as IDs. But if you want to search
doc-entries by user's gender or age for example, then you need some kind
of relationship between these documents.

If you have a 1:n-relation between docs and users you could use
parent/child relations. I use these for document tagging for example,
where the tags are the children of the docs. This way you can search for
docs having a specific tag, but you can also change the tags without the
need to re-index the whole document.

AFAIK there is no simple way to get n:m relations. You have to
denormalize your data in some way.

There is a very helpful blog post about the different possibilities for
"Managing Relations inside Elasticsearch":

Best regards,
Hannes

On 13.02.2015 11:49, noren@sobazaar.com wrote:

Hey,

For the following situation:

doc-entry
{
"id" : 1,
"users" : [1001, 2002],
}

user-entry
{
"id": 1001,
"name": "a"
},
{
"id": 2002,
"name": "b"
}

Lets say I search for doc-entries that contains user_id= 1001, is it
possible for elasticsearch to automatically map the user id to the user
object and return something like:

doc-entry
{
"id" : 1,
"users" : ["a", "b"]
},

And in this case what happens if you want to search doc-estry using a user
name, could elasticsearch automatically lookup the user id and then search
the name field?

I have a very relation db like way of thinking, what would best practice be
when doing something like this in elasticsearch. Could I solve this by
using natural language as id, e.g. using the user name as id

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/54DDEB55.7030500%40hkorte.com.
For more options, visit https://groups.google.com/d/optout.