Index FAQ

Updated at:

This topic covers common questions about configuring shards and replicas, estimating synchronization latency, and enabling pre-sorting for search indexes in ApsaraDB for HBase.

How many shards and replicas should I specify when creating an index?

Start with one shard per service node (M = 1). Scale out only when your data volume exceeds the threshold described below.

Shard limits

Each shard holds at most approximately 2,100,000,000 documents (the INT maximum). Exceeding this limit causes the underlying Lucene layer to overwrite existing documents.

A single shard can become very large. At 2,000,000,000 documents of 1 KB each, a shard reaches roughly 2 TB — enough to overload a service node and cause scan failures. Document size also affects query performance: shards storing 10 KB documents behave differently from those storing 200-byte documents.

When to scale out

For an instance with N service nodes and M shards per node, scale out when:

Total indexed data > N × M × 2,100,000,000

If M exceeds the number of CPUs on a node, scale out the cluster or upgrade the instance. Start at M = 1, then increase to 2, 3, or higher until the formula is satisfied.

Replicas

Set replicationFactor to 1 and autoAddReplicas to false by default. If read loads are significantly higher than write loads, set replicationFactor to 2 or 3 to distribute the read load.

Note

Shard and replica counts can be adjusted after index creation, but specify them at creation time when possible.

How long does it take to synchronize data from HBase tables to search indexes?

Total synchronization latency has two components:

Index synchronization latency = Data synchronization latency + Commit time

  • No pending tasks: Latency equals framework overhead only — typically a few milliseconds.

  • Pending tasks exist: Latency increases. Add more nodes to reduce it.

The default commit time is 15 seconds. For light write loads, lower it to 1s, 3s, or 5s for fresher results. For heavy write loads, keep the default — a short commit time under heavy writes produces many small files that merge frequently, degrading overall performance.

How do I use pre-sorting?

Pre-sorting on a column lets sorted queries terminate early instead of scanning the full dataset. At terabyte scale, this can cut response times dramatically. Configure it in two steps.

Step 1: Configure MergePolicy in solrconfig.xml

Use SortingMergePolicyFactory to wrap the standard TieredMergePolicyFactory. The following example sorts by timestamp in descending order:

<mergePolicyFactory class="org.apache.solr.index.SortingMergePolicyFactory">
  <str name="sort">timestamp desc</str>
  <str name="wrapped.prefix">inner</str>
  <str name="inner.class">org.apache.solr.index.TieredMergePolicyFactory</str>
  <int name="inner.maxMergeAtOnce">10</int>
  <int name="inner.segmentsPerTier">10</int>
</mergePolicyFactory>

For more details, see Customizing merge policies in the Solr reference guide.

Step 2: Set segmentTerminateEarly to true at query time

Pass segmentTerminateEarly=true in your query:

curl "http://localhost:8983/solr/testcollection/query?q=*:*&sort=timestamp+desc&rows=10&segmentTerminateEarly=true"

With segmentTerminateEarly enabled, response times for sorted queries drop significantly.

Note
  • The sort value in your query must match the sort value in the MergePolicy configuration. A mismatch disables pre-sorting entirely.

  • Always include segmentTerminateEarly=true. Without it, all rows are sorted normally and early termination does not apply.

  • When pre-sorting is active, numFound does not return an accurate count.