Single-table mode without slices: Default Slice
When your business needs only a single common table (such as a product catalog table products) and does not require data to be split by tenant or knowledge base, you can configure "default_slice" when you create a collection. After this feature is enabled, all write, read-by-ID, and search requests can omit the _slice (or the SDK routing) parameter, which keeps the call pattern consistent with a traditional single-index Elasticsearch deployment.
All API examples in this topic provide CONSOLE / CURL / GO / PYTHON / JAVASCRIPT / JAVA code tabs (CONSOLE requests can be copied directly into Kibana Dev Tools). The other SDK examples reuse the Quick start environment variables and the client instance initialized there.
1. Use cases and selection boundaries
Comparison | Example request | Applicable scenarios |
Single-table mode without slices (configure |
| Small and medium-sized tables that do not require tenant isolation, such as a single product catalog or a global configuration table. You can directly reuse traditional single-index Elasticsearch code. |
Multi-tenant mode with multiple slices (without |
| Multi-tenant SaaS, multiple knowledge bases, agent memory stores, or scenarios that must exceed the capacity, throughput, or concurrency quota of a single slice. |
For a common single table with an expected data volume ≤ 10 GB, a write throughput ≤ 32 MiB/s, and a query concurrency within the single-slice quota (the single-slice limit is 16; for more information, see Migration guide, error codes, and FAQ), you can directly configure default_slice to simplify integration. Before you make a selection, note the following two boundaries:
Not recommended for multi-tenant tables: When
default_sliceis not configured, omitting_slicereturns400, which blocks the error immediately. After this feature is enabled, omitting_slicereads from and writes tomainby default. In multi-tenant scenarios, data from different tenants can be mixed into the default slice when your code omits the parameter.Use multiple slices when you exceed single-slice capacity: In single-table mode, all traffic is concentrated in the default slice, and
default_slicecannot be renamed or cleared after it is set. If you expect the data volume or concurrency to exceed the capacity of a single slice, plan multiple slices based on your business key before you create the table (see Manage collections and slices (Collection and Slice)).
2. Create a collection with default_slice
In PUT /_slice_collection/{collection}, specify "default_slice": "main":
CONSOLE
// 1. Create a collection with default_slice
PUT /_slice_collection/products
{
"default_slice": "main",
"mappings": {
"dynamic": "strict",
"properties": {
"name": { "type": "text" },
"category": { "type": "keyword" },
"price": { "type": "double" }
}
}
}
// 2. Check the collection configuration to confirm default_slice is in effect
GET /_slice_collection/productsCURL
# 1. Create a collection with default_slice
curl -u "$ES_USER:$ES_PASSWORD" -X PUT \
"$ES_ENDPOINT/_slice_collection/products" \
-H 'Content-Type: application/json' \
--data-binary @- <<'JSON'
{"default_slice":"main","mappings":{"dynamic":"strict","properties":{"name":{"type":"text"},"category":{"type":"keyword"},"price":{"type":"double"}}}}
JSON
# 2. Check the collection configuration to confirm default_slice is in effect
curl -u "$ES_USER:$ES_PASSWORD" \
"$ES_ENDPOINT/_slice_collection/products"GO
// 1. Create a collection with default_slice
req, _ := http.NewRequestWithContext(ctx, "PUT", "/_slice_collection/products",
strings.NewReader(`{"default_slice":"main","mappings":{"dynamic":"strict","properties":{"name":{"type":"text"},"category":{"type":"keyword"},"price":{"type":"double"}}}}`))
req.Header.Set("Content-Type", "application/json")
resp, err := client.Perform(req)
if err != nil {
log.Fatal(err)
}
resp.Body.Close()
// 2. Check the collection configuration to confirm default_slice is in effect
getReq, _ := http.NewRequestWithContext(ctx, "GET", "/_slice_collection/products", nil)
getResp, _ := client.Perform(getReq)
defer getResp.Body.Close()PYTHON
# 1. Create a collection with default_slice
client.perform_request(
"PUT",
"/_slice_collection/products",
headers={"content-type": "application/json"},
body={
"default_slice": "main",
"mappings": {
"dynamic": "strict",
"properties": {
"name": {"type": "text"},
"category": {"type": "keyword"},
"price": {"type": "double"},
},
},
},
)
# 2. Check the collection configuration to confirm default_slice is in effect
info = client.perform_request("GET", "/_slice_collection/products")
print(info)JAVASCRIPT
// 1. Create a collection with default_slice
await client.transport.request({
method: 'PUT',
path: '/_slice_collection/products',
body: {
default_slice: 'main',
mappings: {
dynamic: 'strict',
properties: {
name: { type: 'text' },
category: { type: 'keyword' },
price: { type: 'double' },
},
},
},
})
// 2. Check the collection configuration to confirm default_slice is in effect
const info = await client.transport.request({
method: 'GET',
path: '/_slice_collection/products',
})
console.log(info)JAVA
// 1. Create a collection with default_slice
Request createReq = new Request("PUT", "/_slice_collection/products");
createReq.setJsonEntity("""
{
"default_slice": "main",
"mappings": {
"dynamic": "strict",
"properties": {
"name": { "type": "text" },
"category": { "type": "keyword" },
"price": { "type": "double" }
}
}
}
""");
restClient.performRequest(createReq);
// 2. Check the collection configuration to confirm default_slice is in effect
Response infoResp = restClient.performRequest(new Request("GET", "/_slice_collection/products"));
System.out.println(EntityUtils.toString(infoResp.getEntity()));When you create the collection, the system automatically creates the default slice main. Even if you later disable auto_create_slice, the existing main slice remains readable and writable.
3. Routine reads, writes, and searches (no _slice or routing required)
CONSOLE
// Write a document (written to the main slice automatically)
PUT /products/_doc/p-1001
{
"name": "outdoor hiking backpack",
"category": "outdoor",
"price": 299.0
}
// Read by ID
GET /products/_doc/p-1001
// Search (visible after the background refresh completes a few seconds later)
POST /products/_search?allow_partial_search_results=false
{
"query": {
"term": { "category": "outdoor" }
}
}CURL
# Write a document (written to the main slice automatically)
curl -u "$ES_USER:$ES_PASSWORD" -X PUT \
"$ES_ENDPOINT/products/_doc/p-1001" \
-H 'Content-Type: application/json' \
--data '{"name":"outdoor hiking backpack","category":"outdoor","price":299.0}'
# Read by ID
curl -u "$ES_USER:$ES_PASSWORD" \
"$ES_ENDPOINT/products/_doc/p-1001"
# Search (visible after the background refresh completes a few seconds later)
curl -u "$ES_USER:$ES_PASSWORD" -X POST \
"$ES_ENDPOINT/products/_search?allow_partial_search_results=false" \
-H 'Content-Type: application/json' \
--data '{"query":{"term":{"category":"outdoor"}}}'GO
// Write a document (no Routing required; it lands in the main slice automatically)
if _, err := client.Index("products").
Id("p-1001").
Document(map[string]any{"name": "outdoor hiking backpack", "category": "outdoor", "price": 299.0}).
Do(ctx); err != nil {
log.Fatal(err)
}
// Read by ID in real time
doc, err := client.Get("products", "p-1001").Do(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(doc.Source_))
// Search (visible after the background refresh completes a few seconds later)
searchRes, err := client.Search().
Index("products").
AllowPartialSearchResults(false).
Query(&types.Query{Term: map[string]types.TermQuery{"category": {Value: "outdoor"}}}).
Do(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Println(searchRes.Hits.Hits)PYTHON
# Write a document (no routing required; it lands in the main slice automatically)
client.index(
index="products",
id="p-1001",
document={"name": "outdoor hiking backpack", "category": "outdoor", "price": 299.0},
)
# Read by ID in real time
doc = client.get(index="products", id="p-1001")
# Search (visible after the background refresh completes a few seconds later)
res = client.search(
index="products",
allow_partial_search_results=False,
query={"term": {"category": "outdoor"}},
)JAVASCRIPT
// Write a document (no routing required; it lands in the main slice automatically)
await client.index({
index: 'products',
id: 'p-1001',
document: { name: 'outdoor hiking backpack', category: 'outdoor', price: 299.0 },
})
// Read by ID in real time
const doc = await client.get({ index: 'products', id: 'p-1001' })
// Search (visible after the background refresh completes a few seconds later)
const res = await client.search({
index: 'products',
allow_partial_search_results: false,
query: { term: { category: 'outdoor' } },
})JAVA
// Write a document (written to the main slice automatically)
client.index(i -> i.index("products").id("p-1001")
.document(Map.of("name", "outdoor hiking backpack", "category", "outdoor", "price", 299.0)));
// Read by ID
GetResponse<Map> doc = client.get(g -> g.index("products").id("p-1001"), Map.class);
System.out.println(doc.source());
// Search (visible after the background refresh completes a few seconds later)
SearchResponse<Map> res = client.search(s -> s
.index("products")
.allowPartialSearchResults(false)
.query(q -> q.term(t -> t.field("category").value("outdoor"))),
Map.class);
System.out.println(res.hits().hits());4. Explicitly pass _slice to override the default slice
Even if default_slice is configured, you can still explicitly pass _slice (or the SDK routing) in a single request to read from and write to other slices:
CONSOLE
PUT /products/_doc/p-1001?_slice=other
{
"name": "product in another slice",
"category": "outdoor",
"price": 599.0
}CURL
curl -u "$ES_USER:$ES_PASSWORD" -X PUT \
"$ES_ENDPOINT/products/_doc/p-1001?_slice=other" \
-H 'Content-Type: application/json' \
--data '{"name":"product in another slice","category":"outdoor","price":599.0}'GO
if _, err := client.Index("products").
Id("p-1001").
Routing("other").
Document(map[string]any{"name": "product in another slice", "category": "outdoor", "price": 599.0}).
Do(ctx); err != nil {
log.Fatal(err)
}PYTHON
client.index(
index="products",
id="p-1001",
routing="other",
document={"name": "product in another slice", "category": "outdoor", "price": 599.0},
)JAVASCRIPT
await client.index({
index: 'products',
id: 'p-1001',
routing: 'other',
document: { name: 'product in another slice', category: 'outdoor', price: 599.0 },
})JAVA
client.index(i -> i.index("products").id("p-1001").routing("other")
.document(Map.of("name", "product in another slice", "category", "outdoor", "price", 599.0)));When you omit _slice, reads, writes, and searches access only the default slice main and do not automatically merge queries against other slices such as other. main and other can each store different documents with the same ID (p-1001).
5. Considerations for updates and deletions
The first binding is irreversible: A collection without
default_slicecan be bound for the first time by callingPOST /_slice_collection/{collection}/_update, but it cannot be renamed or cleared after it is set.Behavior after you delete the default slice: If you delete the default slice
main, the"default_slice": "main"configuration on the collection is retained. In this case, a read without_slicereturns404. When you write again without_slice, if the defaultauto_create_slice: trueis enabled, the system automatically recreatesmain. Otherwise, you must register the slice again manually.Clean up the example collection (optional): If you no longer need the example collection
products(if you plan to continue exploring Reduce cold query latency: Warm Slice or Replicate a slice: Copy Slice, wait until you finish both examples before you delete it). You can runDELETE /_slice_collection/products.