Search code examples
search-engineelasticsearchnest

RoutingMissingException while indexing with NEST library


I have specified document mapping in my code using TypeMapping, while indexing I started seeing the following exception

{"error":"RoutingMissingException[routing is required for [search2]/[ImageDocument]/[2039810546]]","status":500}

And I didn't find any way to specify routing using NEST while specifying the typemappings! Any clue where do we specify the routing parameter while indexing or at the time mapping?


Solution

  • We can use IndexParameters argument while indexing and specify the routing

            IndexParameters indexParams = new IndexParameters() { Routing = "id" };
            var resp = ConnectedClient.Index(doc, "IndexName", "typeName", id, indexParams);