Multiple Types within an Index

Am Donnerstag, 20. Februar 2014 04:37:34 UTC+1 schrieb Roland Pirklbauer:

Am Samstag, 5. Januar 2013 12:16:39 UTC+1 schrieb Jörg Prante:

Later while searching, you can direct your search client to the index
"library", and all searches to the "identifier" field will be mapped
correctly to the effective mapping of the underlying identifier field.

Hello,

this is exactly what I need (query the identifier for all types), but I'm
not able to form the correct query. Can someone give me a short example,
how such a query should look like?

My best guess would be:

{
"query_string" : {
"fields" : ["books.identifier",
"cds.identifier","videos.identifier"],
"query" : "123",
}
}

But if a new type is added (and in my usecase the type is dynamic, so I
don't know the possible types right now - but all types will have a set of
common fields), I must update the query - so this is not a good option (for
me).

Thanks a lot
Roland

The answer is quite simple. You can just ignore the type in the fields
name, so the above example should look like: {

"query" : {
"term" : { "identifier": "123" }
}

Hope this can help others with the same simple problem.

--
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/5de08a08-4b9e-476b-a11c-b30de670ffde%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.