Is Mapping per document level possible?

Hello Everyone,

One of my usecase is to support mapping at the document level i.e. each
object to be indexed
has a mapping associated with it.

Is it possible to have mapping at the per document basis? If yes, how can
we do it using java api
at runtime?

Thanks in advance..!!!

My impression is routing is vary much intended to be per document.

The routing information is typically defined in mapping and probably set
to be required.
See Routing on

shards can be configured to route documents with certain routing values
to them

This is allocation is not required.

Then when a document is indexed routine information is either external
to the document or part of the document.

The page

Give an example where a comment document routed to a shard by its
"blog.post_id".
Here is the routine part of the mapping for a comment document.

"{
"comment" : {
"_routing" : {
"required" : true,
"path" : "blog.post_id"
}
}
}

Will cause the following doc to be routed based on the |111222| value:

{
"text" : "the comment text"
"blog" : {
"post_id" : "111222"
}
}"

The example suggests that blog posts also would be routed the same way,
therefore the post and comments end up on the same shard.
On which particular shard both the post and comments end up could be
controlled by features described on the allocation page linked above.

Other examples on the ES site have all tweets for the same user routed
using the same value (the example just use the user login id), so
all the tweets end up together.

That's the long way to say that routing can be any value, so you can do
anything you want on a per document basis.

-Paul

On 7/31/2012 10:26 AM, ajasuja wrote:

Hello Everyone,

One of my usecase is to support mapping at the document level i.e.
each object to be indexed
has a mapping associated with it.

Is it possible to have mapping at the per document basis? If yes, how
can we do it using java api
at runtime?

Thanks in advance..!!!