Skip to content

Commit

Permalink
Update documentation for _routing
Browse files Browse the repository at this point in the history
Signed-off-by: acarbonetto <[email protected]>
  • Loading branch information
acarbonetto committed Jun 27, 2023
1 parent 1d89d9d commit ede3956
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/user/dql/basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ Result set:
One can also provide meta-field name(s) to retrieve reserved-fields (beginning with underscore) from OpenSearch documents. They may also be used
in the query `WHERE` or `ORDER BY` clauses. Meta-fields are not output from wildcard calls (`SELECT *`) and must be explicitly included to be returned.

Note: `_routing` is used differently in the `SELECT` and `WHERE` clauses. In `WHERE`, it contains the routing hash id. In `SELECT`,
it returns the shard used for the query (unless shards aren't active, in which case it returns the routing hash id).

SQL query::

POST /_plugins/_sql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,10 @@ public void testMetafieldIdentifierRoutingFilterTest() throws IOException {
var datarows = result.getJSONArray("datarows");
assertEquals(1, datarows.length());

// note that _routing in the SELECT clause returns the shard
assertEquals("test4", datarows.getJSONArray(0).getString(0));
// note that _routing in the SELECT clause returns the shard, not the routing hash id
assertTrue(datarows.getJSONArray(0).getString(2).contains("[" + index + "]"));

}

@Test
Expand Down

0 comments on commit ede3956

Please sign in to comment.