You can specify a path for your custom routing in your mapping. The
documents will need to contain it in a specific field. Have a look at the routing
field http://www.elasticsearch.org/guide/reference/mapping/routing-field/docs, path section.
You need to add the mapping to your create index request using the
addMapping method.
On Tuesday, September 10, 2013 11:39:57 AM UTC+2, Elod Balazs wrote:
Hi,
Can anyone provide an example on how custom routing on a path can be
achieved via the java API?
Hi Luca - Actually I read somewhere that specifying a routing value using
"path" parameter is expensive since the document needs to be parsed to
retrieve that routing value (apart from the parsing that would be done when
putting it into index). Hence it was recommended to specify routing as a
query param in the url.
You can specify a path for your custom routing in your mapping. The
documents will need to contain it in a specific field. Have a look at the routing
fieldhttp://www.elasticsearch.org/guide/reference/mapping/routing-field/docs, path section.
You need to add the mapping to your create index request using the
addMapping method.
On Tuesday, September 10, 2013 11:39:57 AM UTC+2, Elod Balazs wrote:
Hi,
Can anyone provide an example on how custom routing on a path can be
achieved via the java API?
Hi,
that is true. In a distributed environment, you can send your index
requests to any node in the cluster. Based on the id or the custom routing,
that node will forward the request to all the other nodes where the
document is supposed to be indexed (nodes that hold its primary shard and
all the replicas). That happens without needing to parse the document on
the node that receives the request, unless you have the id or the routing
specified as path in the document itself. It's just an additional step that
needs to happen to determine where the document needs to be sent, not a big
deal since we do pull parsing but still, if you can pass the routing as a
parameter, outside of your document, that's the most recommended way to do
it.
Hi Luca - Actually I read somewhere that specifying a routing value using
"path" parameter is expensive since the document needs to be parsed to
retrieve that routing value (apart from the parsing that would be done when
putting it into index). Hence it was recommended to specify routing as a
query param in the url.
You can specify a path for your custom routing in your mapping. The
documents will need to contain it in a specific field. Have a look at the routing
fieldhttp://www.elasticsearch.org/guide/reference/mapping/routing-field/docs, path section.
You need to add the mapping to your create index request using the
addMapping method.
On Tuesday, September 10, 2013 11:39:57 AM UTC+2, Elod Balazs wrote:
Hi,
Can anyone provide an example on how custom routing on a path can be
achieved via the java API?
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.