Solr
  1. Solr
  2. SOLR-3182

If there is only one core, let it be the default without specifying a default in solr.xml

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.6, 4.0-ALPHA
    • Fix Version/s: None
    • Component/s: multicore
    • Labels:

      Description

      Our particular need for this is as follows. We operate in a sharded environment with one core per server. Each shard also acts as a collator. We want to use a hardware load balancer to choose which shard will do the collation for each query. But in order to do that, each server's single core would have to carry the same name so that it could be accessed by the same url across servers. However we name the cores by their shard number (query0,query1,...) because it parallels with the way we name our indexing/master cores (index0, index1,...). This naming convention also gives us the flexibility of moving to a multicore environment in the future without having to rename the cores, although admittedly that would complicate load balancing.

      In a system with a large number of shards and the anticipation of adding more going forward, setting a defaultCoreName attribute in each solr.xml file becomes inconvenient, especially since there is no Solr admin API for setting defaultCoreName. It would have to be done by hand or with some automated tool we would write in house. Even if there were an API, logically it seems unnecessary to have to declare the only core to be the default.

      Fortunately this behavior can be implemented with the following simple patch:

      Index: solr/core/src/java/org/apache/solr/core/CoreContainer.java
      ===================================================================
      --- solr/core/src/java/org/apache/solr/core/CoreContainer.java	(revision 1295229)
      +++ solr/core/src/java/org/apache/solr/core/CoreContainer.java	(working copy)
      @@ -870,6 +870,10 @@
         }
       
         private String checkDefault(String name) {
      +    // if there is only one core, let it be the default without specifying a default in solr.xml
      +    if (defaultCoreName.trim().length() == 0 && name.trim().length() == 0 && cores.size() == 1) {
      +      return cores.values().iterator().next().getName();
      +    }
           return name.length() == 0  || defaultCoreName.equals(name) || name.trim().length() == 0 ? "" : name;
         } 
      

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            Russell Black
          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:

              Time Tracking

              Estimated:
              Original Estimate - 10m
              10m
              Remaining:
              Remaining Estimate - 10m
              10m
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development