Multiple routing field in elasticsearch Multiple routing field in elasticsearch elasticsearch elasticsearch

Multiple routing field in elasticsearch


In answer to your question: no, you can't automatically use multiple fields for a routing value when indexing a document. You can choose one and only one field, and that field must contain a single value.

However, you could manually concatenate the username and id field and pass it in the indexing request:

PUT /index/type/id?routing=username_id{ body }

That said, routing is a feature for more advanced users. It is very useful but does make life more complicated. You say that you're a newbie, so I'd suggest not playing with routing just yet. That can follow when you're running a 50 node cluster.