lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject svn commit: r890809 [1/2] - in /lucene/solr/branches/cloud: ./ contrib/dataimporthandler/ contrib/dataimporthandler/src/extras/ contrib/dataimporthandler/src/extras/main/ contrib/dataimporthandler/src/extras/main/java/ contrib/dataimporthandler/src/ext...
Date Tue, 15 Dec 2009 14:49:20 GMT
Author: markrmiller
Date: Tue Dec 15 14:49:18 2009
New Revision: 890809

URL: http://svn.apache.org/viewvc?rev=890809&view=rev
Log:
merge cloud branch up to r890798

Added:
    lucene/solr/branches/cloud/contrib/dataimporthandler/solr-dataimporthandler-extras-pom.xml.template
      - copied unchanged from r890798, lucene/solr/trunk/contrib/dataimporthandler/solr-dataimporthandler-extras-pom.xml.template
    lucene/solr/branches/cloud/contrib/dataimporthandler/src/extras/
      - copied from r890798, lucene/solr/trunk/contrib/dataimporthandler/src/extras/
    lucene/solr/branches/cloud/contrib/dataimporthandler/src/extras/main/
      - copied from r890798, lucene/solr/trunk/contrib/dataimporthandler/src/extras/main/
    lucene/solr/branches/cloud/contrib/dataimporthandler/src/extras/main/java/
      - copied from r890798, lucene/solr/trunk/contrib/dataimporthandler/src/extras/main/java/
    lucene/solr/branches/cloud/contrib/dataimporthandler/src/extras/main/java/org/
      - copied from r890798, lucene/solr/trunk/contrib/dataimporthandler/src/extras/main/java/org/
    lucene/solr/branches/cloud/contrib/dataimporthandler/src/extras/main/java/org/apache/
      - copied from r890798, lucene/solr/trunk/contrib/dataimporthandler/src/extras/main/java/org/apache/
    lucene/solr/branches/cloud/contrib/dataimporthandler/src/extras/main/java/org/apache/solr/
      - copied from r890798, lucene/solr/trunk/contrib/dataimporthandler/src/extras/main/java/org/apache/solr/
    lucene/solr/branches/cloud/contrib/dataimporthandler/src/extras/main/java/org/apache/solr/handler/
      - copied from r890798, lucene/solr/trunk/contrib/dataimporthandler/src/extras/main/java/org/apache/solr/handler/
    lucene/solr/branches/cloud/contrib/dataimporthandler/src/extras/main/java/org/apache/solr/handler/dataimport/
      - copied from r890798, lucene/solr/trunk/contrib/dataimporthandler/src/extras/main/java/org/apache/solr/handler/dataimport/
    lucene/solr/branches/cloud/contrib/dataimporthandler/src/extras/main/java/org/apache/solr/handler/dataimport/MailEntityProcessor.java
      - copied, changed from r890798, lucene/solr/trunk/contrib/dataimporthandler/src/extras/main/java/org/apache/solr/handler/dataimport/MailEntityProcessor.java
    lucene/solr/branches/cloud/contrib/dataimporthandler/src/extras/main/java/org/apache/solr/handler/dataimport/TikaEntityProcessor.java
      - copied unchanged from r890798, lucene/solr/trunk/contrib/dataimporthandler/src/extras/main/java/org/apache/solr/handler/dataimport/TikaEntityProcessor.java
    lucene/solr/branches/cloud/contrib/dataimporthandler/src/extras/test/
      - copied from r890798, lucene/solr/trunk/contrib/dataimporthandler/src/extras/test/
    lucene/solr/branches/cloud/contrib/dataimporthandler/src/extras/test/java/
      - copied from r890798, lucene/solr/trunk/contrib/dataimporthandler/src/extras/test/java/
    lucene/solr/branches/cloud/contrib/dataimporthandler/src/extras/test/java/org/
      - copied from r890798, lucene/solr/trunk/contrib/dataimporthandler/src/extras/test/java/org/
    lucene/solr/branches/cloud/contrib/dataimporthandler/src/extras/test/java/org/apache/
      - copied from r890798, lucene/solr/trunk/contrib/dataimporthandler/src/extras/test/java/org/apache/
    lucene/solr/branches/cloud/contrib/dataimporthandler/src/extras/test/java/org/apache/solr/
      - copied from r890798, lucene/solr/trunk/contrib/dataimporthandler/src/extras/test/java/org/apache/solr/
    lucene/solr/branches/cloud/contrib/dataimporthandler/src/extras/test/java/org/apache/solr/handler/
      - copied from r890798, lucene/solr/trunk/contrib/dataimporthandler/src/extras/test/java/org/apache/solr/handler/
    lucene/solr/branches/cloud/contrib/dataimporthandler/src/extras/test/java/org/apache/solr/handler/dataimport/
      - copied from r890798, lucene/solr/trunk/contrib/dataimporthandler/src/extras/test/java/org/apache/solr/handler/dataimport/
    lucene/solr/branches/cloud/contrib/dataimporthandler/src/extras/test/java/org/apache/solr/handler/dataimport/TestMailEntityProcessor.java
      - copied, changed from r890798, lucene/solr/trunk/contrib/dataimporthandler/src/extras/test/java/org/apache/solr/handler/dataimport/TestMailEntityProcessor.java
    lucene/solr/branches/cloud/contrib/dataimporthandler/src/extras/test/java/org/apache/solr/handler/dataimport/TestTikaEntityProcessor.java
      - copied unchanged from r890798, lucene/solr/trunk/contrib/dataimporthandler/src/extras/test/java/org/apache/solr/handler/dataimport/TestTikaEntityProcessor.java
    lucene/solr/branches/cloud/contrib/dataimporthandler/src/extras/test/resources/
      - copied from r890798, lucene/solr/trunk/contrib/dataimporthandler/src/extras/test/resources/
    lucene/solr/branches/cloud/contrib/dataimporthandler/src/extras/test/resources/solr/
      - copied from r890798, lucene/solr/trunk/contrib/dataimporthandler/src/extras/test/resources/solr/
    lucene/solr/branches/cloud/contrib/dataimporthandler/src/extras/test/resources/solr/conf/
      - copied from r890798, lucene/solr/trunk/contrib/dataimporthandler/src/extras/test/resources/solr/conf/
    lucene/solr/branches/cloud/contrib/dataimporthandler/src/extras/test/resources/solr/conf/dataimport-schema-no-unique-key.xml
      - copied unchanged from r890798, lucene/solr/trunk/contrib/dataimporthandler/src/extras/test/resources/solr/conf/dataimport-schema-no-unique-key.xml
    lucene/solr/branches/cloud/contrib/dataimporthandler/src/extras/test/resources/solr/conf/dataimport-solrconfig.xml
      - copied unchanged from r890798, lucene/solr/trunk/contrib/dataimporthandler/src/extras/test/resources/solr/conf/dataimport-solrconfig.xml
    lucene/solr/branches/cloud/example/example-DIH/solr/tika/
      - copied from r890798, lucene/solr/trunk/example/example-DIH/solr/tika/
    lucene/solr/branches/cloud/example/example-DIH/solr/tika/conf/
      - copied from r890798, lucene/solr/trunk/example/example-DIH/solr/tika/conf/
    lucene/solr/branches/cloud/example/example-DIH/solr/tika/conf/schema.xml
      - copied unchanged from r890798, lucene/solr/trunk/example/example-DIH/solr/tika/conf/schema.xml
    lucene/solr/branches/cloud/example/example-DIH/solr/tika/conf/solrconfig.xml
      - copied unchanged from r890798, lucene/solr/trunk/example/example-DIH/solr/tika/conf/solrconfig.xml
    lucene/solr/branches/cloud/example/example-DIH/solr/tika/conf/tika-data-config.xml
      - copied unchanged from r890798, lucene/solr/trunk/example/example-DIH/solr/tika/conf/tika-data-config.xml
    lucene/solr/branches/cloud/example/solr/solr.xml
      - copied unchanged from r890798, lucene/solr/trunk/example/solr/solr.xml
    lucene/solr/branches/cloud/src/java/org/apache/solr/analysis/PatternReplaceCharFilter.java
      - copied unchanged from r890798, lucene/solr/trunk/src/java/org/apache/solr/analysis/PatternReplaceCharFilter.java
    lucene/solr/branches/cloud/src/java/org/apache/solr/analysis/PatternReplaceCharFilterFactory.java
      - copied unchanged from r890798, lucene/solr/trunk/src/java/org/apache/solr/analysis/PatternReplaceCharFilterFactory.java
    lucene/solr/branches/cloud/src/solrj/org/apache/solr/client/solrj/response/TermsResponse.java
      - copied unchanged from r890798, lucene/solr/trunk/src/solrj/org/apache/solr/client/solrj/response/TermsResponse.java
    lucene/solr/branches/cloud/src/test/org/apache/solr/analysis/TestPatternReplaceCharFilter.java
      - copied unchanged from r890798, lucene/solr/trunk/src/test/org/apache/solr/analysis/TestPatternReplaceCharFilter.java
    lucene/solr/branches/cloud/src/test/org/apache/solr/client/solrj/response/TermsResponseTest.java
      - copied unchanged from r890798, lucene/solr/trunk/src/test/org/apache/solr/client/solrj/response/TermsResponseTest.java
    lucene/solr/branches/cloud/src/test/org/apache/solr/handler/component/DistributedTermsComponentTest.java
      - copied unchanged from r890798, lucene/solr/trunk/src/test/org/apache/solr/handler/component/DistributedTermsComponentTest.java
    lucene/solr/branches/cloud/src/test/org/apache/solr/search/QueryParsingTest.java
      - copied unchanged from r890798, lucene/solr/trunk/src/test/org/apache/solr/search/QueryParsingTest.java
    lucene/solr/branches/cloud/src/test/org/apache/solr/search/function/SortByFunctionTest.java
      - copied unchanged from r890798, lucene/solr/trunk/src/test/org/apache/solr/search/function/SortByFunctionTest.java
Modified:
    lucene/solr/branches/cloud/   (props changed)
    lucene/solr/branches/cloud/CHANGES.txt
    lucene/solr/branches/cloud/build.xml
    lucene/solr/branches/cloud/contrib/dataimporthandler/CHANGES.txt
    lucene/solr/branches/cloud/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataConfig.java
    lucene/solr/branches/cloud/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImporter.java
    lucene/solr/branches/cloud/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DocBuilder.java
    lucene/solr/branches/cloud/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/PlainTextEntityProcessor.java
    lucene/solr/branches/cloud/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestDocBuilder2.java
    lucene/solr/branches/cloud/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestErrorHandling.java
    lucene/solr/branches/cloud/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessor2.java
    lucene/solr/branches/cloud/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessorDelta.java
    lucene/solr/branches/cloud/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessorDelta2.java
    lucene/solr/branches/cloud/contrib/dataimporthandler/src/test/resources/solr/conf/dataimport-solrconfig.xml
    lucene/solr/branches/cloud/contrib/dataimporthandler/src/test/resources/solr/conf/single-entity-data-config.xml
    lucene/solr/branches/cloud/example/example-DIH/solr/solr.xml
    lucene/solr/branches/cloud/example/solr/conf/solrconfig.xml
    lucene/solr/branches/cloud/src/common/org/apache/solr/common/params/CoreAdminParams.java
    lucene/solr/branches/cloud/src/common/org/apache/solr/common/params/TermsParams.java
    lucene/solr/branches/cloud/src/common/org/apache/solr/common/util/ConcurrentLRUCache.java
    lucene/solr/branches/cloud/src/java/org/apache/solr/analysis/BaseCharFilterFactory.java
    lucene/solr/branches/cloud/src/java/org/apache/solr/core/CoreContainer.java
    lucene/solr/branches/cloud/src/java/org/apache/solr/core/SolrResourceLoader.java
    lucene/solr/branches/cloud/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java
    lucene/solr/branches/cloud/src/java/org/apache/solr/handler/component/ResponseBuilder.java
    lucene/solr/branches/cloud/src/java/org/apache/solr/handler/component/ShardRequest.java
    lucene/solr/branches/cloud/src/java/org/apache/solr/handler/component/TermsComponent.java
    lucene/solr/branches/cloud/src/java/org/apache/solr/search/FastLRUCache.java
    lucene/solr/branches/cloud/src/java/org/apache/solr/search/LRUCache.java
    lucene/solr/branches/cloud/src/java/org/apache/solr/search/QueryParsing.java
    lucene/solr/branches/cloud/src/java/org/apache/solr/search/SolrCache.java
    lucene/solr/branches/cloud/src/java/org/apache/solr/search/SolrIndexSearcher.java
    lucene/solr/branches/cloud/src/java/org/apache/solr/search/ValueSourceParser.java
    lucene/solr/branches/cloud/src/java/org/apache/solr/search/function/ValueSource.java
    lucene/solr/branches/cloud/src/java/org/apache/solr/search/function/distance/DistanceUtils.java
    lucene/solr/branches/cloud/src/solrj/org/apache/solr/client/solrj/SolrQuery.java
    lucene/solr/branches/cloud/src/solrj/org/apache/solr/client/solrj/impl/StreamingUpdateSolrServer.java
    lucene/solr/branches/cloud/src/solrj/org/apache/solr/client/solrj/response/QueryResponse.java
    lucene/solr/branches/cloud/src/test/org/apache/solr/client/solrj/MultiCoreExampleTestBase.java
    lucene/solr/branches/cloud/src/test/org/apache/solr/client/solrj/SolrQueryTest.java
    lucene/solr/branches/cloud/src/test/org/apache/solr/handler/component/TermsComponentTest.java
    lucene/solr/branches/cloud/src/webapp/web/admin/index.jsp
    lucene/solr/branches/cloud/src/webapp/web/index.jsp

Propchange: lucene/solr/branches/cloud/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Dec 15 14:49:18 2009
@@ -1 +1 @@
-/lucene/solr/trunk:888480-888806
+/lucene/solr/trunk:888480-890798

Modified: lucene/solr/branches/cloud/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/CHANGES.txt?rev=890809&r1=890808&r2=890809&view=diff
==============================================================================
--- lucene/solr/branches/cloud/CHANGES.txt (original)
+++ lucene/solr/branches/cloud/CHANGES.txt Tue Dec 15 14:49:18 2009
@@ -24,6 +24,7 @@
 ==================  1.5.0-dev ==================
 Upgrading from Solr 1.4
 ----------------------
+The experimental ALIAS command is removed in Solr 1.5 (SOLR-1637).
 
 Versions of Major Components
 ---------------------
@@ -56,6 +57,20 @@
 * SOLR-785: Distributed Search support for SpellCheckComponent
   (Matthew Woytowitz, shalin)
 
+* SOLR-1625: Add regexp support for TermsComponent (Uri Boness via noble)
+
+* SOLR-1297: Add sort by Function capability (gsingers)
+
+* SOLR-1139: Add TermsComponent Query and Response Support in SolrJ (Matt Weber via shalin)
+
+* SOLR-1177: Distributed Search support for TermsComponent (Matt Weber via shalin)
+
+* SOLR-1621: Allow current single core deployments to be specified by solr.xml (Mark Miller , noble)
+
+* SOLR-1532: Allow StreamingUpdateSolrServer to use a provided HttpClient (Gabriele Renzi via shalin)
+
+* SOLR-1653: Add PatternReplaceCharFilter (koji)
+
 Optimizations
 ----------------------
 
@@ -124,6 +139,9 @@
   DOMUtils - notably for plugin init params in solrconfig.xml.
   (hossman)
 
+* SOLR-1651: Fixed Incorrect dataimport handler package name in SolrResourceLoader
+  (Akshay Ukey via shalin)
+
 Other Changes
 ----------------------
 
@@ -144,6 +162,10 @@
 
 * Upgraded to Lucene 2.9-dev r888785 (shalin)
 
+* SOLR-1610: Generify SolrCache (Jason Rutherglen via shalin)
+
+* SOLR-1637: Remove ALIAS command
+
 Build
 ----------------------
 
@@ -909,6 +931,8 @@
     Also, HighlightingUtils#getQueryScorer has been removed as it was deprecated and backcompat has been 
     broken with it anyway.  (Mark Miller)
 
+50. SOLR-1357 SolrInputDocument cannot process dynamic fields (Lars Grote via noble)
+
 Build
 ----------------------
  1. SOLR-776: Added in ability to sign artifacts via Ant for releases (gsingers)

Modified: lucene/solr/branches/cloud/build.xml
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/build.xml?rev=890809&r1=890808&r2=890809&view=diff
==============================================================================
--- lucene/solr/branches/cloud/build.xml (original)
+++ lucene/solr/branches/cloud/build.xml Tue Dec 15 14:49:18 2009
@@ -394,6 +394,7 @@
            dir="src/test/test-files/"
            >
       <jvmarg line="${args}"/>
+      <jvmarg line="-Djava.util.logging.config.file=log.properties"/>
       <formatter type="brief" usefile="false" if="junit.details"/>
       <classpath refid="test.run.classpath"/>
       <formatter type="${junit.formatter}"/>

Modified: lucene/solr/branches/cloud/contrib/dataimporthandler/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/contrib/dataimporthandler/CHANGES.txt?rev=890809&r1=890808&r2=890809&view=diff
==============================================================================
--- lucene/solr/branches/cloud/contrib/dataimporthandler/CHANGES.txt (original)
+++ lucene/solr/branches/cloud/contrib/dataimporthandler/CHANGES.txt Tue Dec 15 14:49:18 2009
@@ -21,18 +21,30 @@
 New Features
 ----------------------
 
-* SOLR-1525 allow DIH to refer to core properties (noble)
-* SOLR-1547 TemplateTransformer copy objects more intelligently when there when the template is a single variable (noble)
-* SOLR-1627 VariableResolver should be fetched just in time (noble)
-* SOLR-1583 Create DataSources that return InputStream (noble) 
+* SOLR-1525 : allow DIH to refer to core properties (noble)
+
+* SOLR-1547 : TemplateTransformer copy objects more intelligently when there when the template is a single variable (noble)
+
+* SOLR-1627 : VariableResolver should be fetched just in time (noble)
+
+* SOLR-1583 : Create DataSources that return InputStream (noble)
+
+* SOLR-1358 : Integration of Tika and DataImportHandler ( Akshay Ukey, noble)
+
+* SOLR-1654 : TikaEntityProcessor example added DIHExample (Akshay Ukey via noble)
+
 
 Optimizations
 ----------------------
 
 Bug Fixes
 ----------------------
+* SOLR-1638: Fixed NullPointerException during import if uniqueKey is not specified
+  in schema (Akshay Ukey via shalin)
 
+* SOLR-1639: Fixed misleading error message when dataimport.properties is not writable (shalin)
 
+* SOLR-1598: Reader used in PlainTextEntityProcessor is not explicitly closed (Sascha Szott via noble)
 
 Other Changes
 ----------------------

Copied: lucene/solr/branches/cloud/contrib/dataimporthandler/src/extras/main/java/org/apache/solr/handler/dataimport/MailEntityProcessor.java (from r890798, lucene/solr/trunk/contrib/dataimporthandler/src/extras/main/java/org/apache/solr/handler/dataimport/MailEntityProcessor.java)
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/contrib/dataimporthandler/src/extras/main/java/org/apache/solr/handler/dataimport/MailEntityProcessor.java?p2=lucene/solr/branches/cloud/contrib/dataimporthandler/src/extras/main/java/org/apache/solr/handler/dataimport/MailEntityProcessor.java&p1=lucene/solr/trunk/contrib/dataimporthandler/src/extras/main/java/org/apache/solr/handler/dataimport/MailEntityProcessor.java&r1=890798&r2=890809&rev=890809&view=diff
==============================================================================
    (empty)

Copied: lucene/solr/branches/cloud/contrib/dataimporthandler/src/extras/test/java/org/apache/solr/handler/dataimport/TestMailEntityProcessor.java (from r890798, lucene/solr/trunk/contrib/dataimporthandler/src/extras/test/java/org/apache/solr/handler/dataimport/TestMailEntityProcessor.java)
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/contrib/dataimporthandler/src/extras/test/java/org/apache/solr/handler/dataimport/TestMailEntityProcessor.java?p2=lucene/solr/branches/cloud/contrib/dataimporthandler/src/extras/test/java/org/apache/solr/handler/dataimport/TestMailEntityProcessor.java&p1=lucene/solr/trunk/contrib/dataimporthandler/src/extras/test/java/org/apache/solr/handler/dataimport/TestMailEntityProcessor.java&r1=890798&r2=890809&rev=890809&view=diff
==============================================================================
    (empty)

Modified: lucene/solr/branches/cloud/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataConfig.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataConfig.java?rev=890809&r1=890808&r2=890809&view=diff
==============================================================================
--- lucene/solr/branches/cloud/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataConfig.java (original)
+++ lucene/solr/branches/cloud/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataConfig.java Tue Dec 15 14:49:18 2009
@@ -279,6 +279,12 @@
         dataSources.put(p.getProperty("name"), p);
       }
     }
+    if(dataSources.get(null) == null){
+      for (Properties properties : dataSources.values()) {
+        dataSources.put(null,properties);
+        break;        
+      } 
+    }
   }
 
   private static String getStringAttribute(Element e, String name, String def) {

Modified: lucene/solr/branches/cloud/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImporter.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImporter.java?rev=890809&r1=890808&r2=890809&view=diff
==============================================================================
--- lucene/solr/branches/cloud/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImporter.java (original)
+++ lucene/solr/branches/cloud/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImporter.java Tue Dec 15 14:49:18 2009
@@ -149,8 +149,12 @@
   }
 
   private void identifyPk(DataConfig.Entity entity) {
-    String schemaPk = schema.getUniqueKeyField().getName();
-    //if no fields are mentioned . solr uniqeKey is same as dih 'pk'
+    SchemaField uniqueKey = schema.getUniqueKeyField();
+    String schemaPk = "";
+    if (uniqueKey != null)
+      schemaPk = uniqueKey.getName();
+    else return;
+    //if no fields are mentioned . solr uniqueKey is same as dih 'pk'
     entity.pkMappingFromSchema = schemaPk;
     for (DataConfig.Field field : entity.fields) {
       if(field.getName().equals(schemaPk)) {
@@ -267,7 +271,6 @@
   }
 
   DataSource getDataSourceInstance(DataConfig.Entity key, String name, Context ctx) {
-    if ("null".equals(name)) return new MockDataSource();
     Properties p = dataSourceProps.get(name);
     if (p == null)
       p = config.dataSources.get(name);
@@ -279,15 +282,15 @@
       throw new DataImportHandlerException(SEVERE,
               "No dataSource :" + name + " available for entity :"
                       + key.name);
-    String impl = p.getProperty(TYPE);
+    String type = p.getProperty(TYPE);
     DataSource dataSrc = null;
-    if (impl == null) {
+    if (type == null) {
       dataSrc = new JdbcDataSource();
     } else {
       try {
-        dataSrc = (DataSource) DocBuilder.loadClass(impl, getCore()).newInstance();
+        dataSrc = (DataSource) DocBuilder.loadClass(type, getCore()).newInstance();
       } catch (Exception e) {
-        wrapAndThrow(SEVERE, e, "Invalid type for data source: " + impl);
+        wrapAndThrow(SEVERE, e, "Invalid type for data source: " + type);
       }
     }
     try {

Modified: lucene/solr/branches/cloud/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DocBuilder.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DocBuilder.java?rev=890809&r1=890808&r2=890809&view=diff
==============================================================================
--- lucene/solr/branches/cloud/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DocBuilder.java (original)
+++ lucene/solr/branches/cloud/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DocBuilder.java Tue Dec 15 14:49:18 2009
@@ -229,7 +229,13 @@
       if (requestParameters.optimize)
         addStatusMessage("Optimized");
     }
-    writer.persist(lastIndexTimeProps);
+    try {
+      writer.persist(lastIndexTimeProps);
+    } catch (Exception e) {
+      LOG.error("Could not write property file", e);
+      statusMessages.put("error", "Could not write property file. Delta imports will not work. " +
+          "Make sure your conf directory is writable");
+    }
   }
 
   void rollback() {

Modified: lucene/solr/branches/cloud/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/PlainTextEntityProcessor.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/PlainTextEntityProcessor.java?rev=890809&r1=890808&r2=890809&view=diff
==============================================================================
--- lucene/solr/branches/cloud/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/PlainTextEntityProcessor.java (original)
+++ lucene/solr/branches/cloud/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/PlainTextEntityProcessor.java Tue Dec 15 14:49:18 2009
@@ -19,6 +19,7 @@
 import static org.apache.solr.handler.dataimport.DataImportHandlerException.SEVERE;
 import static org.apache.solr.handler.dataimport.DataImportHandlerException.wrapAndThrow;
 import static org.apache.solr.handler.dataimport.XPathEntityProcessor.URL;
+import org.apache.commons.io.IOUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -77,6 +78,7 @@
     Map<String, Object> row = new HashMap<String, Object>();
     row.put(PLAIN_TEXT, sw.toString());
     ended = true;
+    IOUtils.closeQuietly(r);
     return row;
   }
 

Modified: lucene/solr/branches/cloud/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestDocBuilder2.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestDocBuilder2.java?rev=890809&r1=890808&r2=890809&view=diff
==============================================================================
--- lucene/solr/branches/cloud/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestDocBuilder2.java (original)
+++ lucene/solr/branches/cloud/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestDocBuilder2.java Tue Dec 15 14:49:18 2009
@@ -298,7 +298,7 @@
           "    </document>\n" +
           "</dataConfig>";
 
-   private final String dataConfigWithDynamicTransformer = "<dataConfig>\n" +
+   private final String dataConfigWithDynamicTransformer = "<dataConfig> <dataSource type=\"MockDataSource\"/>\n" +
           "    <document>\n" +
           "        <entity name=\"books\" query=\"select * from x\"" +
            "                transformer=\"TestDocBuilder2$AddDynamicFieldTransformer\">\n" +
@@ -308,7 +308,7 @@
           "    </document>\n" +
           "</dataConfig>";
 
-  private final String dataConfigForSkipTransform = "<dataConfig>\n" +
+  private final String dataConfigForSkipTransform = "<dataConfig> <dataSource  type=\"MockDataSource\"/>\n" +
           "    <document>\n" +
           "        <entity name=\"books\" query=\"select * from x\"" +
            "                transformer=\"TemplateTransformer\">\n" +
@@ -319,7 +319,7 @@
           "    </document>\n" +
           "</dataConfig>";
 
-  private final String dataConfigWithTwoEntities = "<dataConfig>\n" +
+  private final String dataConfigWithTwoEntities = "<dataConfig><dataSource type=\"MockDataSource\"/>\n" +
           "    <document>\n" +
           "        <entity name=\"books\" query=\"select * from x\">" +
           "            <field column=\"id\" />\n" +
@@ -331,7 +331,7 @@
           "    </document>\n" +
           "</dataConfig>";
 
-  private final String dataConfigWithCaseInsensitiveFields = "<dataConfig>\n" +
+  private final String dataConfigWithCaseInsensitiveFields = "<dataConfig> <dataSource  type=\"MockDataSource\"/>\n" +
           "    <document onImportStart=\"TestDocBuilder2$StartEventListener\" onImportEnd=\"TestDocBuilder2$EndEventListener\">\n" +
           "        <entity name=\"books\" query=\"select * from x\">\n" +
           "            <field column=\"ID\" />\n" +
@@ -340,7 +340,7 @@
           "    </document>\n" +
           "</dataConfig>";
 
-  private final String dataConfigWithTemplatizedFieldNames = "<dataConfig>\n" +
+  private final String dataConfigWithTemplatizedFieldNames = "<dataConfig><dataSource  type=\"MockDataSource\"/>\n" +
           "    <document>\n" +
           "        <entity name=\"books\" query=\"select * from x\">\n" +
           "            <field column=\"mypk\" name=\"${dih.request.mypk}\" />\n" +

Modified: lucene/solr/branches/cloud/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestErrorHandling.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestErrorHandling.java?rev=890809&r1=890808&r2=890809&view=diff
==============================================================================
--- lucene/solr/branches/cloud/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestErrorHandling.java (original)
+++ lucene/solr/branches/cloud/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestErrorHandling.java Tue Dec 15 14:49:18 2009
@@ -133,6 +133,7 @@
 
   private String dataConfigWithTransformer = "<dataConfig>\n" +
           "        <dataSource name=\"str\" type=\"TestErrorHandling$StringDataSource\" />" +
+          "<dataSource  type=\"MockDataSource\"/>" +
           "    <document>\n" +
           "        <entity name=\"node\" dataSource=\"str\" processor=\"XPathEntityProcessor\" url=\"test\" forEach=\"/root/node\">\n" +
           "            <field column=\"id\" xpath=\"/root/node/id\" />\n" +

Modified: lucene/solr/branches/cloud/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessor2.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessor2.java?rev=890809&r1=890808&r2=890809&view=diff
==============================================================================
--- lucene/solr/branches/cloud/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessor2.java (original)
+++ lucene/solr/branches/cloud/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessor2.java Tue Dec 15 14:49:18 2009
@@ -218,14 +218,14 @@
     }
   }
 
-  private static String dataConfig_LastIndexTime = "<dataConfig>\n" +
+  private static String dataConfig_LastIndexTime = "<dataConfig><dataSource  type=\"MockDataSource\"/>\n" +
           "\t<function name=\"checkDateFormat\" class=\"org.apache.solr.handler.dataimport.TestSqlEntityProcessor2$DateFormatValidatingEvaluator\"/>\n" +
           "\t<document>\n" +
           "\t\t<entity name=\"x\" query=\"select * from x where last_modified > ${dih.functions.checkDateFormat(dih.last_index_time)}\" />\n" +
           "\t</document>\n" +
           "</dataConfig>";
 
-  private static String dataConfig = "<dataConfig>\n"
+  private static String dataConfig = "<dataConfig><dataSource  type=\"MockDataSource\"/>\n"
           + "       <document>\n"
           + "               <entity name=\"x\" pk=\"id\" query=\"select * from x\" deletedPkQuery=\"select id from x where last_modified > NOW AND deleted='true'\" deltaQuery=\"select id from x where last_modified > NOW\">\n"
           + "                       <field column=\"id\" />\n"
@@ -234,7 +234,7 @@
           + "                       </entity>\n" + "               </entity>\n"
           + "       </document>\n" + "</dataConfig>\n";
 
-  private static String dataConfig_deltaimportquery = "<dataConfig>\n"
+  private static String dataConfig_deltaimportquery = "<dataConfig><dataSource  type=\"MockDataSource\"/>\n"
           + "       <document>\n"
           + "               <entity name=\"x\" deltaImportQuery=\"select * from x where id=${dataimporter.delta.id}\" deltaQuery=\"select id from x where last_modified > NOW\">\n"
           + "                       <field column=\"id\" />\n"

Modified: lucene/solr/branches/cloud/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessorDelta.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessorDelta.java?rev=890809&r1=890808&r2=890809&view=diff
==============================================================================
--- lucene/solr/branches/cloud/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessorDelta.java (original)
+++ lucene/solr/branches/cloud/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessorDelta.java Tue Dec 15 14:49:18 2009
@@ -279,7 +279,7 @@
     assertQ(req("desc:goodbye"), "//*[@numFound='1']");
   }
 
-  private static String dataConfig_delta = "<dataConfig>\n"
+  private static String dataConfig_delta = "<dataConfig><dataSource  type=\"MockDataSource\"/>\n"
     + "       <document>\n"
     + "               <entity name=\"x\" transformer=\"TemplateTransformer\""
     + "				query=\"" + FULLIMPORT_QUERY + "\""

Modified: lucene/solr/branches/cloud/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessorDelta2.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessorDelta2.java?rev=890809&r1=890808&r2=890809&view=diff
==============================================================================
--- lucene/solr/branches/cloud/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessorDelta2.java (original)
+++ lucene/solr/branches/cloud/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessorDelta2.java Tue Dec 15 14:49:18 2009
@@ -275,7 +275,7 @@
     assertQ(req("desc:goodbye"), "//*[@numFound='1']");
   }
 
-  private static String dataConfig_delta2 = "<dataConfig>\n"
+  private static String dataConfig_delta2 = "<dataConfig><dataSource  type=\"MockDataSource\"/>\n"
     + "       <document>\n"
     + "               <entity name=\"x\" transformer=\"TemplateTransformer\""
     + "				query=\"" + FULLIMPORT_QUERY + "\""

Modified: lucene/solr/branches/cloud/contrib/dataimporthandler/src/test/resources/solr/conf/dataimport-solrconfig.xml
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/contrib/dataimporthandler/src/test/resources/solr/conf/dataimport-solrconfig.xml?rev=890809&r1=890808&r2=890809&view=diff
==============================================================================
--- lucene/solr/branches/cloud/contrib/dataimporthandler/src/test/resources/solr/conf/dataimport-solrconfig.xml (original)
+++ lucene/solr/branches/cloud/contrib/dataimporthandler/src/test/resources/solr/conf/dataimport-solrconfig.xml Tue Dec 15 14:49:18 2009
@@ -328,11 +328,6 @@
   </requestHandler>
   
   <requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
-    <lst name="defaults">
-      <lst name="datasource">
-         <str name="type">MockDataSource</str>
-      </lst>
-    </lst>
   </requestHandler>
     
   <!--

Modified: lucene/solr/branches/cloud/contrib/dataimporthandler/src/test/resources/solr/conf/single-entity-data-config.xml
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/contrib/dataimporthandler/src/test/resources/solr/conf/single-entity-data-config.xml?rev=890809&r1=890808&r2=890809&view=diff
==============================================================================
--- lucene/solr/branches/cloud/contrib/dataimporthandler/src/test/resources/solr/conf/single-entity-data-config.xml (original)
+++ lucene/solr/branches/cloud/contrib/dataimporthandler/src/test/resources/solr/conf/single-entity-data-config.xml Tue Dec 15 14:49:18 2009
@@ -1,4 +1,5 @@
 <dataConfig>
+  <dataSource type="MockDataSource"/>
 	<document>
 		<entity name="x" query="select * from x">
 			<field column="id" />

Modified: lucene/solr/branches/cloud/example/example-DIH/solr/solr.xml
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/example/example-DIH/solr/solr.xml?rev=890809&r1=890808&r2=890809&view=diff
==============================================================================
--- lucene/solr/branches/cloud/example/example-DIH/solr/solr.xml (original)
+++ lucene/solr/branches/cloud/example/example-DIH/solr/solr.xml Tue Dec 15 14:49:18 2009
@@ -1,8 +1,9 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <solr sharedLib="lib" persistent="true">
 	<cores adminPath="/admin/cores">
-		<core default="true" instanceDir="db" name="db"></core>
-		<core default="false" instanceDir="rss" name="rss"></core>
-		<core default="false" instanceDir="mail" name="mail"></core>
+		<core default="true" instanceDir="db" name="db"/>
+		<core default="false" instanceDir="rss" name="rss"/>
+		<core default="false" instanceDir="mail" name="mail"/>
+		<core default="false" instanceDir="tika" name="tika"/>
 	</cores>
 </solr>

Modified: lucene/solr/branches/cloud/example/solr/conf/solrconfig.xml
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/example/solr/conf/solrconfig.xml?rev=890809&r1=890808&r2=890809&view=diff
==============================================================================
--- lucene/solr/branches/cloud/example/solr/conf/solrconfig.xml (original)
+++ lucene/solr/branches/cloud/example/solr/conf/solrconfig.xml Tue Dec 15 14:49:18 2009
@@ -792,8 +792,7 @@
   </requestHandler>
 
 
-  <!-- A component to return terms and document frequency of those terms.
-       This component does not yet support distributed search. -->
+  <!-- A component to return terms and document frequency of those terms. -->
   <searchComponent name="termsComponent" class="org.apache.solr.handler.component.TermsComponent"/>
 
   <requestHandler name="/terms" class="org.apache.solr.handler.component.SearchHandler">

Modified: lucene/solr/branches/cloud/src/common/org/apache/solr/common/params/CoreAdminParams.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/common/org/apache/solr/common/params/CoreAdminParams.java?rev=890809&r1=890808&r2=890809&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/common/org/apache/solr/common/params/CoreAdminParams.java (original)
+++ lucene/solr/branches/cloud/src/common/org/apache/solr/common/params/CoreAdminParams.java Tue Dec 15 14:49:18 2009
@@ -66,6 +66,7 @@
     PERSIST,
     SWAP,
     RENAME,
+    @Deprecated
     ALIAS,
     MERGEINDEXES;
     

Modified: lucene/solr/branches/cloud/src/common/org/apache/solr/common/params/TermsParams.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/common/org/apache/solr/common/params/TermsParams.java?rev=890809&r1=890808&r2=890809&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/common/org/apache/solr/common/params/TermsParams.java (original)
+++ lucene/solr/branches/cloud/src/common/org/apache/solr/common/params/TermsParams.java Tue Dec 15 14:49:18 2009
@@ -17,6 +17,7 @@
 
 package org.apache.solr.common.params;
 
+import java.util.regex.Pattern;
 
 /**
  *
@@ -68,7 +69,32 @@
 
   public static final String TERMS_PREFIX_STR = TERMS_PREFIX + "prefix";
 
-  /**
+  public static final String TERMS_REGEXP_STR = TERMS_PREFIX + "regex";
+
+  public static final String TERMS_REGEXP_FLAG = TERMS_REGEXP_STR + ".flag";
+
+  public static enum TermsRegexpFlag {
+      UNIX_LINES(Pattern.UNIX_LINES),
+      CASE_INSENSITIVE(Pattern.CASE_INSENSITIVE),
+      COMMENTS(Pattern.COMMENTS),
+      MULTILINE(Pattern.MULTILINE),
+      LITERAL(Pattern.LITERAL),
+      DOTALL(Pattern.DOTALL),
+      UNICODE_CASE(Pattern.UNICODE_CASE),
+      CANON_EQ(Pattern.CANON_EQ);
+
+      int value;
+
+      TermsRegexpFlag(int value) {
+          this.value = value;
+      }
+
+      public int getValue() {
+          return value;
+      }
+  }
+
+    /**
    * Optional.  The minimum value of docFreq to be returned.  1 by default
    */
   public static final String TERMS_MINCOUNT = TERMS_PREFIX + "mincount";

Modified: lucene/solr/branches/cloud/src/common/org/apache/solr/common/util/ConcurrentLRUCache.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/common/org/apache/solr/common/util/ConcurrentLRUCache.java?rev=890809&r1=890808&r2=890809&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/common/org/apache/solr/common/util/ConcurrentLRUCache.java (original)
+++ lucene/solr/branches/cloud/src/common/org/apache/solr/common/util/ConcurrentLRUCache.java Tue Dec 15 14:49:18 2009
@@ -44,7 +44,7 @@
 public class ConcurrentLRUCache<K,V> {
   private static Logger log = LoggerFactory.getLogger(ConcurrentLRUCache.class);
 
-  private final ConcurrentHashMap<Object, CacheEntry> map;
+  private final ConcurrentHashMap<Object, CacheEntry<K,V>> map;
   private final int upperWaterMark, lowerWaterMark;
   private final ReentrantLock markAndSweepLock = new ReentrantLock(true);
   private boolean isCleaning = false;  // not volatile... piggybacked on other volatile vars
@@ -62,7 +62,7 @@
     if (upperWaterMark < 1) throw new IllegalArgumentException("upperWaterMark must be > 0");
     if (lowerWaterMark >= upperWaterMark)
       throw new IllegalArgumentException("lowerWaterMark must be  < upperWaterMark");
-    map = new ConcurrentHashMap<Object, CacheEntry>(initialSize);
+    map = new ConcurrentHashMap<Object, CacheEntry<K,V>>(initialSize);
     newThreadForCleanup = runNewThreadForCleanup;
     this.upperWaterMark = upperWaterMark;
     this.lowerWaterMark = lowerWaterMark;
@@ -102,10 +102,10 @@
     return null;
   }
 
-  public Object put(K key, V val) {
+  public V put(K key, V val) {
     if (val == null) return null;
-    CacheEntry e = new CacheEntry(key, val, stats.accessCounter.incrementAndGet());
-    CacheEntry oldCacheEntry = map.put(key, e);
+    CacheEntry<K,V> e = new CacheEntry<K,V>(key, val, stats.accessCounter.incrementAndGet());
+    CacheEntry<K,V> oldCacheEntry = map.put(key, e);
     int currentSize;
     if (oldCacheEntry == null) {
       currentSize = stats.size.incrementAndGet();
@@ -401,7 +401,7 @@
     Map<K, V> result = new LinkedHashMap<K, V>();
     TreeSet<CacheEntry> tree = new TreeSet<CacheEntry>();
     try {
-      for (Map.Entry<Object, CacheEntry> entry : map.entrySet()) {
+      for (Map.Entry<Object, CacheEntry<K,V>> entry : map.entrySet()) {
         CacheEntry ce = entry.getValue();
         ce.lastAccessedCopy = ce.lastAccessed;
         if (tree.size() < n) {
@@ -428,8 +428,8 @@
     Map<K,V> result = new LinkedHashMap<K,V>();
     TreeSet<CacheEntry> tree = new TreeSet<CacheEntry>();
     try {
-      for (Map.Entry<Object, CacheEntry> entry : map.entrySet()) {
-        CacheEntry ce = entry.getValue();
+      for (Map.Entry<Object, CacheEntry<K,V>> entry : map.entrySet()) {
+        CacheEntry<K,V> ce = entry.getValue();
         ce.lastAccessedCopy = ce.lastAccessed;
         if (tree.size() < n) {
           tree.add(ce);
@@ -457,11 +457,11 @@
     map.clear();
   }
 
-  public Map<Object, CacheEntry> getMap() {
+  public Map<Object, CacheEntry<K,V>> getMap() {
     return map;
   }
 
-  private static class CacheEntry<K,V> implements Comparable<CacheEntry> {
+  private static class CacheEntry<K,V> implements Comparable<CacheEntry<K,V>> {
     K key;
     V value;
     volatile long lastAccessed = 0;
@@ -478,7 +478,7 @@
       this.lastAccessed = lastAccessed;
     }
 
-    public int compareTo(CacheEntry that) {
+    public int compareTo(CacheEntry<K,V> that) {
       if (this.lastAccessedCopy == that.lastAccessedCopy) return 0;
       return this.lastAccessedCopy < that.lastAccessedCopy ? 1 : -1;
     }

Modified: lucene/solr/branches/cloud/src/java/org/apache/solr/analysis/BaseCharFilterFactory.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/java/org/apache/solr/analysis/BaseCharFilterFactory.java?rev=890809&r1=890808&r2=890809&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/java/org/apache/solr/analysis/BaseCharFilterFactory.java (original)
+++ lucene/solr/branches/cloud/src/java/org/apache/solr/analysis/BaseCharFilterFactory.java Tue Dec 15 14:49:18 2009
@@ -43,4 +43,20 @@
     this.args = args;
   }
 
+  protected int getInt(String name) {
+    return getInt(name,-1,false);
+  }
+
+  protected int getInt(String name, int defaultVal) {
+    return getInt(name,defaultVal,true);
+  }
+
+  protected int getInt(String name, int defaultVal, boolean useDefault) {
+    String s = args.get(name);
+    if (s==null) {
+      if (useDefault) return defaultVal;
+      throw new RuntimeException("Configuration Error: missing parameter '" + name + "'");
+    }
+    return Integer.parseInt(s);
+  }
 }

Modified: lucene/solr/branches/cloud/src/java/org/apache/solr/core/CoreContainer.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/java/org/apache/solr/core/CoreContainer.java?rev=890809&r1=890808&r2=890809&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/java/org/apache/solr/core/CoreContainer.java (original)
+++ lucene/solr/branches/cloud/src/java/org/apache/solr/core/CoreContainer.java Tue Dec 15 14:49:18 2009
@@ -17,14 +17,7 @@
 
 package org.apache.solr.core;
 
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.io.InputStream;
+import java.io.*;
 import java.nio.channels.FileChannel;
 import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
@@ -42,7 +35,6 @@
 import org.apache.solr.common.params.CoreAdminParams;
 import org.apache.solr.common.util.DOMUtil;
 import org.apache.solr.common.util.XML;
-import org.apache.solr.common.util.StrUtils;
 import org.apache.solr.common.util.FileUtils;
 import org.apache.solr.handler.admin.CoreAdminHandler;
 import org.apache.solr.schema.IndexSchema;
@@ -58,6 +50,8 @@
  */
 public class CoreContainer 
 {
+  private static final String DEFAULT_CORE_NAME = "DEFAULT_CORE";
+
   protected static Logger log = LoggerFactory.getLogger(CoreContainer.class);
   
   protected final Map<String, SolrCore> cores = new LinkedHashMap<String, SolrCore>();
@@ -69,28 +63,31 @@
   protected String libDir = null;
   protected ClassLoader libLoader = null;
   protected SolrResourceLoader loader = null;
+  @Deprecated
   protected java.lang.ref.WeakReference<SolrCore> adminCore = null;
   protected Properties containerProperties;
   protected Map<String ,IndexSchema> indexSchemaCache;
   protected String adminHandler;
   protected boolean shareSchema;
   protected String solrHome;
+  protected String solrConfigFilenameOverride;
+  protected String solrDataDirOverride;
   protected static final String collection = System.getProperty("collection", "collection1"); //nocommit: default;
 
   private ZooKeeperController zooKeeperController;
 
   public CoreContainer() {
     solrHome = SolrResourceLoader.locateSolrHome();
+    initZooKeeper();
   }
   
-  public CoreContainer(ZooKeeperController zooKeeperController) {
-    this();
-    this.zooKeeperController = zooKeeperController;
-  }
-  
-  public CoreContainer(String solrHome, ZooKeeperController zooKeeperController) {
-    this.solrHome = solrHome;
-    this.zooKeeperController = zooKeeperController;
+  private void initZooKeeper() {
+    //nocommit: pull zookeeper integration into a new CoreContainer? leaning towards no.
+    String zookeeperHost = System.getProperty("zkHost");
+    
+    if (zookeeperHost != null) {
+      zooKeeperController = new ZooKeeperController(zookeeperHost, collection);
+    }
   }
 
   public Properties getContainerProperties() {
@@ -102,9 +99,6 @@
     protected String solrConfigFilename = null;
     protected boolean abortOnConfigurationError = true;
     protected String dataDir = null; // override datadir for single core mode
-    
-    private ZooKeeperController zooKeeperController;
-    private String zookeeperHost;
 
     public boolean isAbortOnConfigurationError() {
       return abortOnConfigurationError;
@@ -124,78 +118,30 @@
 
     // core container instantiation
     public CoreContainer initialize() throws IOException, ParserConfigurationException, SAXException {
-      //nocommit: pull zookeeper integration into a new CoreContainer? leaning towards no.
-      zookeeperHost = System.getProperty("zkHost");
-      
-      if (zookeeperHost != null) {
-        zooKeeperController = new ZooKeeperController(zookeeperHost, collection);
-      }
-      
       CoreContainer cores = null;
       String solrHome = SolrResourceLoader.locateSolrHome();
-      
-      File fconf = null;
-
-      fconf = new File(solrHome, solrConfigFilename == null ? "solr.xml"
+      File fconf = new File(solrHome, solrConfigFilename == null ? "solr.xml"
           : solrConfigFilename);
       log.info("looking for solr.xml: " + fconf.getAbsolutePath());
-      
-      if (fconf.exists()) {
-        //nocommit: finish ZooKeeper support in multicore case
-        if (zookeeperHost == null) {
-          cores = new CoreContainer();
-        } else {
-          cores = new CoreContainer(zooKeeperController);
-        }
+      cores = new CoreContainer();
+      cores.solrConfigFilenameOverride = solrConfigFilename;
+      cores.solrDataDirOverride = dataDir;
+      if (fconf.exists())
         cores.load(solrHome, fconf);
-        abortOnConfigurationError = false;
-        // if any core aborts on startup, then abort
-        for (SolrCore c : cores.getCores()) {
-          if (c.getSolrConfig().getBool("abortOnConfigurationError", false)) {
-            abortOnConfigurationError = true;
-            break;
-          }
+      else {
+        cores.load(solrHome, new ByteArrayInputStream(DEF_SOLR_XML.getBytes()));
+        cores.configFile = fconf;
+      }
+      abortOnConfigurationError = false;
+      // if any core aborts on startup, then abort
+      for (SolrCore c : cores.getCores()) {
+        if (c.getSolrConfig().getBool("abortOnConfigurationError", false)) {
+          abortOnConfigurationError = true;
+          break;
         }
-        solrConfigFilename = cores.getConfigFile().getName();
-      } else {
-        // perform compatibility init
-        SolrResourceLoader resourceLoader;
-        CoreDescriptor dcore;
-        if (zookeeperHost == null) {
-          cores = new CoreContainer(solrHome);
-           new CoreDescriptor(cores, "", ".");
-          dcore = new CoreDescriptor(cores, "", ".");
-          dcore.setCoreProperties(null);
-          resourceLoader = new SolrResourceLoader(solrHome, null, getCoreProps(solrHome, null, dcore.getCoreProperties()));
-        } else {
-          cores = new CoreContainer(solrHome, zooKeeperController);
-          dcore = new CoreDescriptor(cores, "", ".");
-          dcore.setCoreProperties(null);
-          resourceLoader = new ZKSolrResourceLoader(solrHome, collection, null, getCoreProps(solrHome, null, dcore.getCoreProperties()), zooKeeperController);
-        }
-       
-        cores.loader = resourceLoader;
-        SolrConfig cfg;
-        IndexSchema schema = null;
-        String solrConfigName = solrConfigFilename == null ? SolrConfig.DEFAULT_CONF_FILE : solrConfigFilename;
-        if (zookeeperHost == null) {
-          cfg = new SolrConfig(resourceLoader, solrConfigName, null);
-        } else {
-          // found ZooKeeper path, so load config from zookeeper
-          log.info("Loading config from ZooKeeper");
-          // load solrconfig
-          cfg = zooKeeperController.getConfig(solrConfigName, resourceLoader);
-          // load schema
-          schema = zooKeeperController.getSchema(IndexSchema.DEFAULT_SCHEMA_FILE, cfg, resourceLoader);
-        }
-        
-        SolrCore singlecore = new SolrCore(null, dataDir, cfg, schema, dcore);
-        abortOnConfigurationError = cfg.getBool(
-                "abortOnConfigurationError", abortOnConfigurationError);
-        cores.register("", singlecore, false);
-        cores.setPersistent(false);
-        solrConfigFilename = cfg.getName();
       }
+      solrConfigFilename = cores.getConfigFile().getName();
+      
       return cores;
     }
   }
@@ -231,7 +177,7 @@
    * @throws IOException
    * @throws SAXException
    */
-  public CoreContainer(String dir, File configFile ) throws ParserConfigurationException, IOException, SAXException 
+  public CoreContainer(String dir, File configFile) throws ParserConfigurationException, IOException, SAXException 
   {
     this.load(dir, configFile);
   }
@@ -243,10 +189,12 @@
   public CoreContainer(SolrResourceLoader loader) {
     this.loader = loader;
     this.solrHome = loader.getInstanceDir();
+    initZooKeeper();
   }
 
   public CoreContainer(String solrHome) {
     this.solrHome = solrHome;
+    initZooKeeper();
   }
 
   //-------------------------------------------------------------------
@@ -263,9 +211,23 @@
    */
   public void load(String dir, File configFile ) throws ParserConfigurationException, IOException, SAXException {
     this.configFile = configFile;
+    this.load(dir, new FileInputStream(configFile));
+  } 
+
+  /**
+   * Load a config file listing the available solr cores.
+   * 
+   * @param dir the home directory of all resources.
+   * @param cfgis the configuration file InputStream
+   * @param configName
+   * @throws ParserConfigurationException
+   * @throws IOException
+   * @throws SAXException
+   */
+  public void load(String dir, InputStream cfgis)
+      throws ParserConfigurationException, IOException, SAXException {
     this.loader = new SolrResourceLoader(dir);
     solrHome = loader.getInstanceDir();
-    FileInputStream cfgis = new FileInputStream(configFile);
     try {
       Config cfg = new Config(loader, null, cfgis, null);
 
@@ -274,7 +236,7 @@
       adminPath  = cfg.get(     "solr/cores/@adminPath", null );
       shareSchema = cfg.getBool("solr/cores/@shareSchema", false );
       if(shareSchema){
-        indexSchemaCache = new ConcurrentHashMap<String,IndexSchema>();
+        indexSchemaCache = new ConcurrentHashMap<String ,IndexSchema>();
       }
       adminHandler  = cfg.get("solr/cores/@adminHandler", null );
       managementPath  = cfg.get("solr/cores/@managementPath", null );
@@ -301,21 +263,23 @@
       }
 
       NodeList nodes = (NodeList)cfg.evaluate("solr/cores/core", XPathConstants.NODESET);
-
+      boolean defaultCoreFound = false;
       for (int i=0; i<nodes.getLength(); i++) {
         Node node = nodes.item(i);
         try {
-          String names = DOMUtil.getAttr(node, "name", null);
-          List<String> aliases = StrUtils.splitSmart(names,',');
-          String name = "";
-          if(aliases.size() > 0) {
-            name = aliases.get(0);
+          String name = DOMUtil.getAttr(node, "name", null);
+          if(name.equals(DEFAULT_CORE_NAME)){
+            if(defaultCoreFound) throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,"Only one 'DEFAULT_CORE' is allowed ");            
+            defaultCoreFound = true;
+            name="";
           }
           CoreDescriptor p = new CoreDescriptor(this, name, DOMUtil.getAttr(node, "instanceDir", null));
 
           // deal with optional settings
           String opt = DOMUtil.getAttr(node, "config", null);
-          if (opt != null) {
+          if(solrConfigFilenameOverride != null && name.equals("")) {
+            p.setConfigName(solrConfigFilenameOverride);
+          } else if (opt != null) {
             p.setConfigName(opt);
           }
           opt = DOMUtil.getAttr(node, "schema", null);
@@ -327,19 +291,15 @@
             p.setPropertiesName(opt);
           }
           opt = DOMUtil.getAttr(node, CoreAdminParams.DATA_DIR, null);
-          if (opt != null) {
+          if(solrDataDirOverride != null && name.equals("")) {
+            p.setDataDir(solrDataDirOverride);
+          }else if (opt != null) {
             p.setDataDir(opt);
           }
 
           p.setCoreProperties(readProperties(cfg, node));
 
           SolrCore core = create(p);
-
-          for (int a=1; a<aliases.size(); a++) {
-            core.open();
-            register(aliases.get(a), core, false);
-          }
-
           register(name, core, false);
         }
         catch (Throwable ex) {
@@ -455,15 +415,11 @@
    */
   public SolrCore create(CoreDescriptor dcore)  throws ParserConfigurationException, IOException, SAXException {
     // Make the instanceDir relative to the cores instanceDir if not absolute
-    String instanceDir = dcore.getInstanceDir();
-    File idir;
-      idir = new File(instanceDir);
-      if (!idir.isAbsolute()) {
-        idir = new File(solrHome, instanceDir);
-      }
-
-    instanceDir = idir.getPath();
-    System.out.println("instancedir:" + idir.getAbsolutePath());
+    File idir = new File(dcore.getInstanceDir());
+    if (!idir.isAbsolute()) {
+      idir = new File(solrHome, dcore.getInstanceDir());
+    }
+    String instanceDir = idir.getPath();
     
     // Initialize the solr config
     SolrResourceLoader solrLoader ;
@@ -566,6 +522,7 @@
    */
 
   public void reload(String name) throws ParserConfigurationException, IOException, SAXException {
+    name= checkDefault(name);
     SolrCore core;
     synchronized(cores) {
       core = cores.get(name);
@@ -574,19 +531,13 @@
       throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "No such core: " + name );
 
     SolrCore newCore = create(core.getCoreDescriptor());
-
-    // point all aliases to the reloaded core
-    for (String alias : getCoreNames(core)) {
-      if (!name.equals(alias)) {
-        newCore.open();
-        register(alias, newCore, false);
-      }
-    }
-
     register(name, newCore, false);
   }
-    
-  
+
+  private String checkDefault(String name) {
+    return name.length() == 0  || DEFAULT_CORE_NAME.equals(name) || name.trim().length() == 0 ? "" : name;
+  } 
+
   /**
    * Swaps two SolrCore descriptors.
    * @param n0
@@ -596,6 +547,8 @@
     if( n0 == null || n1 == null ) {
       throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "Can not swap unnamed cores." );
     }
+    n0 = checkDefault(n0);
+    n1 = checkDefault(n1);
     synchronized( cores ) {
       SolrCore c0 = cores.get(n0);
       SolrCore c1 = cores.get(n1);
@@ -607,7 +560,9 @@
       cores.put(n1, c0);
 
       c0.setName(n1);
+      c0.getCoreDescriptor().name = n1;
       c1.setName(n0);
+      c1.getCoreDescriptor().name = n0;
     }
 
 
@@ -616,6 +571,7 @@
   
   /** Removes and returns registered core w/o decrementing it's reference count */
   public SolrCore remove( String name ) {
+    name = checkDefault(name);    
     synchronized(cores) {
       return cores.remove( name );
     }
@@ -629,6 +585,7 @@
    * @return the core if found
    */
   public SolrCore getCore(String name) {
+    name= checkDefault(name);
     synchronized(cores) {
       SolrCore core = cores.get(name);
       if (core != null)
@@ -795,26 +752,12 @@
     if(shareSchema) writeAttribute(w, "shareSchema","true");
     w.write(">\n");
 
-    Map<SolrCore, LinkedList<String>> aliases = new HashMap<SolrCore,LinkedList<String>>();
-
     synchronized(cores) {
-      for (Map.Entry<String, SolrCore> entry : cores.entrySet()) {
-        String name = entry.getKey();
-        LinkedList<String> a = aliases.get(entry.getValue());
-        if (a==null) a = new LinkedList<String>();
-        if (name.equals(entry.getValue().getName())) {
-          a.addFirst(name);
-        } else {
-          a.addLast(name);
-        }
-        aliases.put(entry.getValue(), a);
+      for (SolrCore solrCore : cores.values()) {
+        persist(w,solrCore.getCoreDescriptor());
       }
     }
 
-    for (Map.Entry<SolrCore, LinkedList<String>> entry : aliases.entrySet()) {
-      persist(w, entry.getValue(), entry.getKey().getCoreDescriptor());
-    }
-
     w.write("</cores>\n");
     w.write("</solr>\n");
   }
@@ -829,9 +772,9 @@
   }
   
   /** Writes the cores configuration node for a given core. */
-  void persist(Writer w, List<String> aliases, CoreDescriptor dcore) throws IOException {
+  void persist(Writer w, CoreDescriptor dcore) throws IOException {
     w.write("  <core");
-    writeAttribute(w,"name",StrUtils.join(aliases,','));
+    writeAttribute(w,"name",dcore.name);
     writeAttribute(w,"instanceDir",dcore.getInstanceDir());
     //write config (if not default)
     String opt = dcore.getConfigName();
@@ -906,13 +849,18 @@
   public String getSolrHome() {
     return solrHome;
   }
-  
-  //nocommit: consider - used for testing now
+  private static final String DEF_SOLR_XML ="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
+          "<solr persistent=\"false\">\n" +
+          "  <cores adminPath=\"/admin/cores\">\n" +
+          "    <core name=\""+ DEFAULT_CORE_NAME + "\" instanceDir=\".\" />\n" +
+          "  </cores>\n" +
+          "</solr>";
+
+  // nocommit: consider - for tests now
   public boolean isZooKeeperAware() {
     return zooKeeperController != null;
   }
   
-  // may return null
   public ZooKeeperController getZooKeeperController() {
     return zooKeeperController;
   }

Modified: lucene/solr/branches/cloud/src/java/org/apache/solr/core/SolrResourceLoader.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/java/org/apache/solr/core/SolrResourceLoader.java?rev=890809&r1=890808&r2=890809&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/java/org/apache/solr/core/SolrResourceLoader.java (original)
+++ lucene/solr/branches/cloud/src/java/org/apache/solr/core/SolrResourceLoader.java Tue Dec 15 14:49:18 2009
@@ -63,7 +63,7 @@
 
   static final String project = "solr";
   static final String base = "org.apache" + "." + project;
-  static final String[] packages = {"","analysis.","schema.","handler.","search.","update.","core.","request.","update.processor.","util.", "spelling.", "handler.component.", "handler.dataimport"};
+  static final String[] packages = {"","analysis.","schema.","handler.","search.","update.","core.","request.","update.processor.","util.", "spelling.", "handler.component.", "handler.dataimport."};
 
   protected URLClassLoader classLoader;
   private final String instanceDir;

Modified: lucene/solr/branches/cloud/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java?rev=890809&r1=890808&r2=890809&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java (original)
+++ lucene/solr/branches/cloud/src/java/org/apache/solr/handler/admin/CoreAdminHandler.java Tue Dec 15 14:49:18 2009
@@ -41,7 +41,9 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Date;
+import java.util.Set;
 
 /**
  * @version $Id$
@@ -118,8 +120,8 @@
         }
 
         case ALIAS: {
-          doPersist = this.handleAliasAction(req, rsp);
-          break;
+          throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "'ALIAS' is not supported " +
+            req.getParams().get(CoreAdminParams.ACTION));
         }
 
         case UNLOAD: {
@@ -291,6 +293,7 @@
    * @return true if a modification has resulted that requires persistance 
    *         of the CoreContainer configuration.
    */
+  @Deprecated
   protected boolean handleAliasAction(SolrQueryRequest req, SolrQueryResponse rsp) {
     SolrParams params = req.getParams();
 

Modified: lucene/solr/branches/cloud/src/java/org/apache/solr/handler/component/ResponseBuilder.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/java/org/apache/solr/handler/component/ResponseBuilder.java?rev=890809&r1=890808&r2=890809&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/java/org/apache/solr/handler/component/ResponseBuilder.java (original)
+++ lucene/solr/branches/cloud/src/java/org/apache/solr/handler/component/ResponseBuilder.java Tue Dec 15 14:49:18 2009
@@ -45,6 +45,7 @@
   public boolean doHighlights;
   public boolean doFacets;
   public boolean doStats;
+  public boolean doTerms;
 
   private boolean needDocList = false;
   private boolean needDocSet = false;
@@ -132,6 +133,7 @@
   /* private... components that don't own these shouldn't use them */
   SolrDocumentList _responseDocs;
   StatsInfo _statsInfo;
+  TermsComponent.TermsHelper _termsHelper;
 
   /**
    * Utility function to add debugging info.  This will make sure a valid

Modified: lucene/solr/branches/cloud/src/java/org/apache/solr/handler/component/ShardRequest.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/java/org/apache/solr/handler/component/ShardRequest.java?rev=890809&r1=890808&r2=890809&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/java/org/apache/solr/handler/component/ShardRequest.java (original)
+++ lucene/solr/branches/cloud/src/java/org/apache/solr/handler/component/ShardRequest.java Tue Dec 15 14:49:18 2009
@@ -36,6 +36,7 @@
   public final static int PURPOSE_GET_HIGHLIGHTS  = 0x80;
   public final static int PURPOSE_GET_DEBUG       =0x100;
   public final static int PURPOSE_GET_STATS       =0x200;
+  public final static int PURPOSE_GET_TERMS       =0x400;
 
   public int purpose;  // the purpose of this request
 

Modified: lucene/solr/branches/cloud/src/java/org/apache/solr/handler/component/TermsComponent.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/java/org/apache/solr/handler/component/TermsComponent.java?rev=890809&r1=890808&r2=890809&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/java/org/apache/solr/handler/component/TermsComponent.java (original)
+++ lucene/solr/branches/cloud/src/java/org/apache/solr/handler/component/TermsComponent.java Tue Dec 15 14:49:18 2009
@@ -20,17 +20,23 @@
 import org.apache.lucene.index.TermEnum;
 import org.apache.lucene.util.StringHelper;
 import org.apache.solr.common.SolrException;
-import org.apache.solr.common.params.CommonParams;
-import org.apache.solr.common.params.SolrParams;
-import org.apache.solr.common.params.TermsParams;
+import org.apache.solr.common.params.*;
 import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.SimpleOrderedMap;
+import org.apache.solr.common.util.StrUtils;
 import org.apache.solr.schema.FieldType;
 import org.apache.solr.schema.StrField;
 import org.apache.solr.request.SimpleFacets.CountPair;
 import org.apache.solr.util.BoundedTreeSet;
 
-import java.io.IOException;
+import org.apache.solr.client.solrj.response.TermsResponse;
 
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.regex.Pattern;
 
 /**
  * Return TermEnum information, useful for things like auto suggest.
@@ -40,7 +46,25 @@
  */
 public class TermsComponent extends SearchComponent {
   public static final int UNLIMITED_MAX_COUNT = -1;
+  public static final String COMPONENT_NAME = "terms";
 
+  @Override
+  public void prepare(ResponseBuilder rb) throws IOException {
+    SolrParams params = rb.req.getParams();
+    if (params.getBool(TermsParams.TERMS, false)) {
+      rb.doTerms = true;
+    }
+
+    // TODO: temporary... this should go in a different component.
+    String shards = params.get(ShardParams.SHARDS);
+    if (shards != null) {
+      if (params.get(ShardParams.SHARDS_QT) == null) {
+        throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "No shards.qt parameter specified");
+      }
+      List<String> lst = StrUtils.splitSmart(shards, ",", true);
+      rb.shards = lst.toArray(new String[lst.size()]);
+    }
+  }
 
   public void process(ResponseBuilder rb) throws IOException {
     SolrParams params = rb.req.getParams();
@@ -65,6 +89,9 @@
           freqmax = Integer.MAX_VALUE;
         }
         String prefix = params.get(TermsParams.TERMS_PREFIX_STR);
+        String regexp = params.get(TermsParams.TERMS_REGEXP_STR);
+        Pattern pattern = regexp != null ? Pattern.compile(regexp, resolveRegexpFlags(params)) : null;
+
         boolean raw = params.getBool(TermsParams.TERMS_RAW, false);
         for (int j = 0; j < fields.length; j++) {
           String field = StringHelper.intern(fields[j]);
@@ -105,6 +132,11 @@
             // stop if the prefix doesn't match
             if (prefix != null && !indexedText.startsWith(prefix)) break;
 
+            if (pattern != null && !pattern.matcher(indexedText).matches()) {
+                termEnum.next();
+                continue;
+            }
+
             if (upperTerm != null) {
               int upperCmp = theTerm.compareTo(upperTerm);
               // if we are past the upper term, or equal to it (when don't include upper) then stop.
@@ -146,8 +178,248 @@
     }
   }
 
-  public void prepare(ResponseBuilder rb) throws IOException {
-    //nothing to do
+  int resolveRegexpFlags(SolrParams params) {
+      String[] flagParams = params.getParams(TermsParams.TERMS_REGEXP_FLAG);
+      if (flagParams == null) {
+          return 0;
+      }
+      int flags = 0;
+      for (String flagParam : flagParams) {
+          try {
+            flags |= TermsParams.TermsRegexpFlag.valueOf(flagParam.toUpperCase()).getValue();
+          } catch (IllegalArgumentException iae) {
+              throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Unknown terms regex flag '" + flagParam + "'");
+          }
+      }
+      return flags;
+  }
+
+  @Override
+  public int distributedProcess(ResponseBuilder rb) throws IOException {
+    if (!rb.doTerms) {
+      return ResponseBuilder.STAGE_DONE;
+    }
+
+    if (rb.stage == ResponseBuilder.STAGE_EXECUTE_QUERY) {
+      TermsHelper th = rb._termsHelper;
+      if (th == null) {
+        th = rb._termsHelper = new TermsHelper();
+        th.init(rb.req.getParams());
+      }
+      ShardRequest sreq = createShardQuery(rb.req.getParams());
+      rb.addRequest(this, sreq);
+    }
+
+    if (rb.stage < ResponseBuilder.STAGE_EXECUTE_QUERY) {
+      return ResponseBuilder.STAGE_EXECUTE_QUERY;
+    } else {
+      return ResponseBuilder.STAGE_DONE;
+    }
+  }
+
+  @Override
+  public void handleResponses(ResponseBuilder rb, ShardRequest sreq) {
+    if (!rb.doTerms || (sreq.purpose & ShardRequest.PURPOSE_GET_TERMS) == 0) {
+      return;
+    }
+    TermsHelper th = rb._termsHelper;
+    if (th != null) {
+      for (ShardResponse srsp : sreq.responses) {
+        th.parse((NamedList) srsp.getSolrResponse().getResponse().get("terms"));
+      }
+    }
+  }
+
+  @Override
+  public void finishStage(ResponseBuilder rb) {
+    if (!rb.doTerms || rb.stage != ResponseBuilder.STAGE_EXECUTE_QUERY) {
+      return;
+    }
+
+    TermsHelper ti = rb._termsHelper;
+    NamedList terms = ti.buildResponse();
+
+    rb.rsp.add("terms", terms);
+    rb._termsHelper = null;
+  }
+
+  private ShardRequest createShardQuery(SolrParams params) {
+    ShardRequest sreq = new ShardRequest();
+    sreq.purpose = ShardRequest.PURPOSE_GET_TERMS;
+
+    // base shard request on original parameters
+    sreq.params = new ModifiableSolrParams(params);
+
+    // don't pass through the shards param
+    sreq.params.remove(ShardParams.SHARDS);
+
+    // remove any limits for shards, we want them to return all possible
+    // responses
+    // we want this so we can calculate the correct counts
+    // dont sort by count to avoid that unnecessary overhead on the shards
+    sreq.params.remove(TermsParams.TERMS_MAXCOUNT);
+    sreq.params.remove(TermsParams.TERMS_MINCOUNT);
+    sreq.params.set(TermsParams.TERMS_LIMIT, -1);
+    sreq.params.set(TermsParams.TERMS_SORT, TermsParams.TERMS_SORT_INDEX);
+
+    // TODO: is there a better way to handle this?
+    String qt = params.get(CommonParams.QT);
+    if (qt != null) {
+      sreq.params.add(CommonParams.QT, qt);
+    }
+    return sreq;
+  }
+
+  public class TermsHelper {
+    // map to store returned terms
+    private HashMap<String, HashMap<String, TermsResponse.Term>> fieldmap;
+    private SolrParams params;
+
+    public TermsHelper() {
+      fieldmap = new HashMap<String, HashMap<String, TermsResponse.Term>>(5);
+    }
+
+    public void init(SolrParams params) {
+      this.params = params;
+      String[] fields = params.getParams(TermsParams.TERMS_FIELD);
+      if (fields != null) {
+        for (String field : fields) {
+          // TODO: not sure 128 is the best starting size
+          // It use it because that is what is used for facets
+          fieldmap.put(field, new HashMap<String, TermsResponse.Term>(128));
+        }
+      }
+    }
+
+    public void parse(NamedList terms) {
+      // exit if there is no terms
+      if (terms == null) {
+        return;
+      }
+
+      TermsResponse termsResponse = new TermsResponse(terms);
+      
+      // loop though each field and add each term+freq to map
+      for (String key : fieldmap.keySet()) {
+        HashMap<String, TermsResponse.Term> termmap = fieldmap.get(key);
+        List<TermsResponse.Term> termlist = termsResponse.getTerms(key); 
+
+        // skip this field if there are no terms
+        if (termlist == null) {
+          continue;
+        }
+
+        // loop though each term
+        for (TermsResponse.Term tc : termlist) {
+          String term = tc.getTerm();
+          if (termmap.containsKey(term)) {
+            TermsResponse.Term oldtc = termmap.get(term);
+            oldtc.addFrequency(tc.getFrequency());
+            termmap.put(term, oldtc);
+          } else {
+            termmap.put(term, tc);
+          }
+        }
+      }
+    }
+
+    public NamedList buildResponse() {
+      NamedList response = new SimpleOrderedMap();
+
+      // determine if we are going index or count sort
+      boolean sort = !TermsParams.TERMS_SORT_INDEX.equals(params.get(
+          TermsParams.TERMS_SORT, TermsParams.TERMS_SORT_COUNT));
+
+      // init minimum frequency
+      long freqmin = 1;
+      String s = params.get(TermsParams.TERMS_MINCOUNT);
+      if (s != null)  freqmin = Long.parseLong(s);
+
+      // init maximum frequency, default to max int
+      long freqmax = -1;
+      s = params.get(TermsParams.TERMS_MAXCOUNT);
+      if (s != null)  freqmax = Long.parseLong(s);
+      if (freqmax < 0) {
+        freqmax = Long.MAX_VALUE;
+      }
+
+      // init limit, default to max int
+      long limit = 10;
+      s = params.get(TermsParams.TERMS_LIMIT);
+      if (s != null)  limit = Long.parseLong(s);
+      if (limit < 0) {
+        limit = Long.MAX_VALUE;
+      }
+
+      // loop though each field we want terms from
+      for (String key : fieldmap.keySet()) {
+        NamedList fieldterms = new SimpleOrderedMap();
+        TermsResponse.Term[] data = null;
+        if (sort) {
+          data = getCountSorted(fieldmap.get(key));
+        } else {
+          data = getLexSorted(fieldmap.get(key));
+        }
+
+        // loop though each term until we hit limit
+        int cnt = 0;
+        for (TermsResponse.Term tc : data) {
+          if (tc.getFrequency() >= freqmin && tc.getFrequency() <= freqmax) {
+            fieldterms.add(tc.getTerm(), num(tc.getFrequency()));
+            cnt++;
+          }
+
+          if (cnt >= limit) {
+            break;
+          }
+        }
+
+        response.add(key, fieldterms);
+      }
+
+      return response;
+    }
+
+    // use <int> tags for smaller facet counts (better back compatibility)
+    private Number num(long val) {
+      if (val < Integer.MAX_VALUE) return (int) val;
+      else return val;
+    }
+
+    // based on code from facets
+    public TermsResponse.Term[] getLexSorted(HashMap<String, TermsResponse.Term> data) {
+      TermsResponse.Term[] arr = data.values().toArray(new TermsResponse.Term[data.size()]);
+
+      Arrays.sort(arr, new Comparator<TermsResponse.Term>() {
+        public int compare(TermsResponse.Term o1, TermsResponse.Term o2) {
+          return o1.getTerm().compareTo(o2.getTerm());
+        }
+      });
+
+      return arr;
+    }
+
+    // based on code from facets
+    public TermsResponse.Term[] getCountSorted(HashMap<String, TermsResponse.Term> data) {
+      TermsResponse.Term[] arr = data.values().toArray(new TermsResponse.Term[data.size()]);
+
+      Arrays.sort(arr, new Comparator<TermsResponse.Term>() {
+        public int compare(TermsResponse.Term o1, TermsResponse.Term o2) {
+          long freq1 = o1.getFrequency();
+          long freq2 = o2.getFrequency();
+          
+          if (freq2 < freq1) {
+            return -1;
+          } else if (freq1 < freq2) {
+            return 1;
+          } else {
+            return o1.getTerm().compareTo(o2.getTerm());
+          }
+        }
+      });
+
+      return arr;
+    }
   }
 
   public String getVersion() {

Modified: lucene/solr/branches/cloud/src/java/org/apache/solr/search/FastLRUCache.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/java/org/apache/solr/search/FastLRUCache.java?rev=890809&r1=890808&r2=890809&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/java/org/apache/solr/search/FastLRUCache.java (original)
+++ lucene/solr/branches/cloud/src/java/org/apache/solr/search/FastLRUCache.java Tue Dec 15 14:49:18 2009
@@ -43,7 +43,7 @@
  * @see org.apache.solr.search.SolrCache
  * @since solr 1.4
  */
-public class FastLRUCache implements SolrCache {
+public class FastLRUCache<K,V> implements SolrCache<K,V> {
 
   private List<ConcurrentLRUCache.Stats> cumulativeStats;
 
@@ -54,7 +54,7 @@
   private State state;
   private CacheRegenerator regenerator;
   private String description = "Concurrent LRU Cache";
-  private ConcurrentLRUCache cache;
+  private ConcurrentLRUCache<K,V> cache;
   private int showItems = 0;
 
   public Object init(Map args, Object persistence, CacheRegenerator regenerator) {
@@ -101,7 +101,7 @@
     }
     description += ')';
 
-    cache = new ConcurrentLRUCache(limit, minLimit, acceptableLimit, initialSize, newThread, false, null);
+    cache = new ConcurrentLRUCache<K,V>(limit, minLimit, acceptableLimit, initialSize, newThread, false, null);
     cache.setAlive(false);
 
     if (persistence == null) {
@@ -125,11 +125,11 @@
 
   }
 
-  public Object put(Object key, Object value) {
+  public V put(K key, V value) {
     return cache.put(key, value);
   }
 
-  public Object get(Object key) {
+  public V get(K key) {
     return cache.get(key);
 
   }

Modified: lucene/solr/branches/cloud/src/java/org/apache/solr/search/LRUCache.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/java/org/apache/solr/search/LRUCache.java?rev=890809&r1=890808&r2=890809&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/java/org/apache/solr/search/LRUCache.java (original)
+++ lucene/solr/branches/cloud/src/java/org/apache/solr/search/LRUCache.java Tue Dec 15 14:49:18 2009
@@ -31,7 +31,7 @@
 /**
  * @version $Id$
  */
-public class LRUCache implements SolrCache {
+public class LRUCache<K,V> implements SolrCache<K,V> {
 
   /* An instance of this class will be shared across multiple instances
    * of an LRUCache at the same time.  Make sure everything is thread safe.
@@ -54,7 +54,7 @@
 
   private long warmupTime = 0;
 
-  private Map map;
+  private Map<K,V> map;
   private String name;
   private int autowarmCount;
   private State state;
@@ -79,7 +79,7 @@
     }
     description += ')';
 
-    map = new LinkedHashMap(initialSize, 0.75f, true) {
+    map = new LinkedHashMap<K,V>(initialSize, 0.75f, true) {
         protected boolean removeEldestEntry(Map.Entry eldest) {
           if (size() > limit) {
             // increment evictions regardless of state.
@@ -113,7 +113,7 @@
     }
   }
 
-  public Object put(Object key, Object value) {
+  public V put(K key, V value) {
     synchronized (map) {
       if (state == State.LIVE) {
         stats.inserts.incrementAndGet();
@@ -126,9 +126,9 @@
     }
   }
 
-  public Object get(Object key) {
+  public V get(K key) {
     synchronized (map) {
-      Object val = map.get(key);
+      V val = map.get(key);
       if (state == State.LIVE) {
         // only increment lookups and hits if we are live.
         lookups++;
@@ -156,10 +156,10 @@
     return state;
   }
 
-  public void warm(SolrIndexSearcher searcher, SolrCache old) throws IOException {
+  public void warm(SolrIndexSearcher searcher, SolrCache<K,V> old) throws IOException {
     if (regenerator==null) return;
     long warmingStartTime = System.currentTimeMillis();
-    LRUCache other = (LRUCache)old;
+    LRUCache<K,V> other = (LRUCache<K,V>)old;
 
     // warm entries
     if (autowarmCount != 0) {
@@ -172,7 +172,7 @@
         keys = new Object[sz];
         vals = new Object[sz];
 
-        Iterator iter = other.map.entrySet().iterator();
+        Iterator<Map.Entry<K, V>> iter = other.map.entrySet().iterator();
 
         // iteration goes from oldest (least recently used) to most recently used,
         // so we need to skip over the oldest entries.
@@ -181,7 +181,7 @@
 
 
         for (int i=0; i<sz; i++) {
-          Map.Entry entry = (Map.Entry)iter.next();
+          Map.Entry<K,V> entry = iter.next();
           keys[i]=entry.getKey();
           vals[i]=entry.getValue();
         }



Mime
View raw message