You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2012/03/26 14:59:12 UTC

svn commit: r1305339 [3/3] - in /lucene/dev/trunk: dev-tools/idea/.idea/libraries/ lucene/contrib/highlighter/src/java/org/apache/lucene/search/highlight/ lucene/contrib/highlighter/src/java/org/apache/lucene/search/vectorhighlight/ lucene/contrib/high...

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/DocSetDelegateCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/DocSetDelegateCollector.java?rev=1305339&r1=1305338&r2=1305339&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/DocSetDelegateCollector.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/DocSetDelegateCollector.java Mon Mar 26 12:58:58 2012
@@ -1,85 +1,85 @@
-package org.apache.solr.search;
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.AtomicReaderContext;
-import org.apache.lucene.search.Collector;
-import org.apache.lucene.search.Scorer;
-import org.apache.lucene.util.OpenBitSet;
-
-import java.io.IOException;
-
-/**
- *
- */
-public class DocSetDelegateCollector extends DocSetCollector {
-  final Collector collector;
-
-  public DocSetDelegateCollector(int smallSetSize, int maxDoc, Collector collector) {
-    super(smallSetSize, maxDoc);
-    this.collector = collector;
-  }
-
-  @Override
-  public void collect(int doc) throws IOException {
-    collector.collect(doc);
-
-    doc += base;
-    // optimistically collect the first docs in an array
-    // in case the total number will be small enough to represent
-    // as a small set like SortedIntDocSet instead...
-    // Storing in this array will be quicker to convert
-    // than scanning through a potentially huge bit vector.
-    // FUTURE: when search methods all start returning docs in order, maybe
-    // we could have a ListDocSet() and use the collected array directly.
-    if (pos < scratch.length) {
-      scratch[pos]=doc;
-    } else {
-      // this conditional could be removed if BitSet was preallocated, but that
-      // would take up more memory, and add more GC time...
-      if (bits==null) bits = new OpenBitSet(maxDoc);
-      bits.fastSet(doc);
-    }
-
-    pos++;
-  }
-
-  @Override
-  public DocSet getDocSet() {
-    if (pos<=scratch.length) {
-      // assumes docs were collected in sorted order!
-      return new SortedIntDocSet(scratch, pos);
-    } else {
-      // set the bits for ids that were collected in the array
-      for (int i=0; i<scratch.length; i++) bits.fastSet(scratch[i]);
-      return new BitDocSet(bits,pos);
-    }
-  }
-
-  @Override
-  public void setScorer(Scorer scorer) throws IOException {
-    collector.setScorer(scorer);
-  }
-
-  @Override
-  public void setNextReader(AtomicReaderContext context) throws IOException {
-    collector.setNextReader(context);
-    this.base = context.docBase;
-  }
-}
+package org.apache.solr.search;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.search.Collector;
+import org.apache.lucene.search.Scorer;
+import org.apache.lucene.util.OpenBitSet;
+
+import java.io.IOException;
+
+/**
+ *
+ */
+public class DocSetDelegateCollector extends DocSetCollector {
+  final Collector collector;
+
+  public DocSetDelegateCollector(int smallSetSize, int maxDoc, Collector collector) {
+    super(smallSetSize, maxDoc);
+    this.collector = collector;
+  }
+
+  @Override
+  public void collect(int doc) throws IOException {
+    collector.collect(doc);
+
+    doc += base;
+    // optimistically collect the first docs in an array
+    // in case the total number will be small enough to represent
+    // as a small set like SortedIntDocSet instead...
+    // Storing in this array will be quicker to convert
+    // than scanning through a potentially huge bit vector.
+    // FUTURE: when search methods all start returning docs in order, maybe
+    // we could have a ListDocSet() and use the collected array directly.
+    if (pos < scratch.length) {
+      scratch[pos]=doc;
+    } else {
+      // this conditional could be removed if BitSet was preallocated, but that
+      // would take up more memory, and add more GC time...
+      if (bits==null) bits = new OpenBitSet(maxDoc);
+      bits.fastSet(doc);
+    }
+
+    pos++;
+  }
+
+  @Override
+  public DocSet getDocSet() {
+    if (pos<=scratch.length) {
+      // assumes docs were collected in sorted order!
+      return new SortedIntDocSet(scratch, pos);
+    } else {
+      // set the bits for ids that were collected in the array
+      for (int i=0; i<scratch.length; i++) bits.fastSet(scratch[i]);
+      return new BitDocSet(bits,pos);
+    }
+  }
+
+  @Override
+  public void setScorer(Scorer scorer) throws IOException {
+    collector.setScorer(scorer);
+  }
+
+  @Override
+  public void setNextReader(AtomicReaderContext context) throws IOException {
+    collector.setNextReader(context);
+    this.base = context.docBase;
+  }
+}

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/FunctionRangeQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/FunctionRangeQuery.java?rev=1305339&r1=1305338&r2=1305339&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/FunctionRangeQuery.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/FunctionRangeQuery.java Mon Mar 26 12:58:58 2012
@@ -1,70 +1,70 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.solr.search;
-
-import org.apache.lucene.index.AtomicReaderContext;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.queries.function.FunctionValues;
-import org.apache.lucene.queries.function.ValueSource;
-import org.apache.lucene.queries.function.ValueSourceScorer;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.solr.search.function.ValueSourceRangeFilter;
-
-import java.io.IOException;
-import java.util.Map;
-
-// This class works as either a normal constant score query, or as a PostFilter using a collector
-public class FunctionRangeQuery extends SolrConstantScoreQuery implements PostFilter {
-  final ValueSourceRangeFilter rangeFilt;
-
-  public FunctionRangeQuery(ValueSourceRangeFilter filter) {
-    super(filter);
-    this.rangeFilt = filter;
-  }
-
-  @Override
-  public DelegatingCollector getFilterCollector(IndexSearcher searcher) {
-    Map fcontext = ValueSource.newContext(searcher);
-    return new FunctionRangeCollector(fcontext);
-  }
-
-  class FunctionRangeCollector extends DelegatingCollector {
-    final Map fcontext;
-    ValueSourceScorer scorer;
-    int maxdoc;
-
-    public FunctionRangeCollector(Map fcontext) {
-      this.fcontext = fcontext;
-    }
-
-    @Override
-    public void collect(int doc) throws IOException {
-      if (doc<maxdoc && scorer.matches(doc)) {
-        delegate.collect(doc);
-      }
-    }
-
-    @Override
-    public void setNextReader(AtomicReaderContext context) throws IOException {
-      maxdoc = context.reader().maxDoc();
-      FunctionValues dv = rangeFilt.getValueSource().getValues(fcontext, context);
-      scorer = dv.getRangeScorer(context.reader(), rangeFilt.getLowerVal(), rangeFilt.getUpperVal(), rangeFilt.isIncludeLower(), rangeFilt.isIncludeUpper());
-      super.setNextReader(context);
-    }
-  }
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.search;
+
+import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.queries.function.FunctionValues;
+import org.apache.lucene.queries.function.ValueSource;
+import org.apache.lucene.queries.function.ValueSourceScorer;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.solr.search.function.ValueSourceRangeFilter;
+
+import java.io.IOException;
+import java.util.Map;
+
+// This class works as either a normal constant score query, or as a PostFilter using a collector
+public class FunctionRangeQuery extends SolrConstantScoreQuery implements PostFilter {
+  final ValueSourceRangeFilter rangeFilt;
+
+  public FunctionRangeQuery(ValueSourceRangeFilter filter) {
+    super(filter);
+    this.rangeFilt = filter;
+  }
+
+  @Override
+  public DelegatingCollector getFilterCollector(IndexSearcher searcher) {
+    Map fcontext = ValueSource.newContext(searcher);
+    return new FunctionRangeCollector(fcontext);
+  }
+
+  class FunctionRangeCollector extends DelegatingCollector {
+    final Map fcontext;
+    ValueSourceScorer scorer;
+    int maxdoc;
+
+    public FunctionRangeCollector(Map fcontext) {
+      this.fcontext = fcontext;
+    }
+
+    @Override
+    public void collect(int doc) throws IOException {
+      if (doc<maxdoc && scorer.matches(doc)) {
+        delegate.collect(doc);
+      }
+    }
+
+    @Override
+    public void setNextReader(AtomicReaderContext context) throws IOException {
+      maxdoc = context.reader().maxDoc();
+      FunctionValues dv = rangeFilt.getValueSource().getValues(fcontext, context);
+      scorer = dv.getRangeScorer(context.reader(), rangeFilt.getLowerVal(), rangeFilt.getUpperVal(), rangeFilt.isIncludeLower(), rangeFilt.isIncludeUpper());
+      super.setNextReader(context);
+    }
+  }
+}

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/grouping/collector/FilterCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/grouping/collector/FilterCollector.java?rev=1305339&r1=1305338&r2=1305339&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/grouping/collector/FilterCollector.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/grouping/collector/FilterCollector.java Mon Mar 26 12:58:58 2012
@@ -1,76 +1,76 @@
-package org.apache.solr.search.grouping.collector;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.apache.lucene.index.AtomicReaderContext;
-import org.apache.lucene.search.Collector;
-import org.apache.lucene.search.Scorer;
-import org.apache.solr.search.DocSet;
-
-import java.io.IOException;
-
-/**
- * A collector that filters incoming doc ids that are not in the filter.
- *
- * @lucene.experimental
- */
-public class FilterCollector extends Collector {
-
-  private final DocSet filter;
-  private final Collector delegate;
-  private int docBase;
-  private int matches;
-
-  public FilterCollector(DocSet filter, Collector delegate) throws IOException {
-    this.filter = filter;
-    this.delegate = delegate;
-  }
-
-  public void setScorer(Scorer scorer) throws IOException {
-    delegate.setScorer(scorer);
-  }
-
-  public void collect(int doc) throws IOException {
-    matches++;
-    if (filter.exists(doc + docBase)) {
-      delegate.collect(doc);
-    }
-  }
-
-  public void setNextReader(AtomicReaderContext context) throws IOException {
-    this.docBase = context.docBase;
-    delegate.setNextReader(context);
-  }
-
-  public boolean acceptsDocsOutOfOrder() {
-    return delegate.acceptsDocsOutOfOrder();
-  }
-
-  public int getMatches() {
-    return matches;
-  }
-
-  /**
-   * Returns the delegate collector
-   *
-   * @return the delegate collector
-   */
-  public Collector getDelegate() {
-    return delegate;
-  }
-}
+package org.apache.solr.search.grouping.collector;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.search.Collector;
+import org.apache.lucene.search.Scorer;
+import org.apache.solr.search.DocSet;
+
+import java.io.IOException;
+
+/**
+ * A collector that filters incoming doc ids that are not in the filter.
+ *
+ * @lucene.experimental
+ */
+public class FilterCollector extends Collector {
+
+  private final DocSet filter;
+  private final Collector delegate;
+  private int docBase;
+  private int matches;
+
+  public FilterCollector(DocSet filter, Collector delegate) throws IOException {
+    this.filter = filter;
+    this.delegate = delegate;
+  }
+
+  public void setScorer(Scorer scorer) throws IOException {
+    delegate.setScorer(scorer);
+  }
+
+  public void collect(int doc) throws IOException {
+    matches++;
+    if (filter.exists(doc + docBase)) {
+      delegate.collect(doc);
+    }
+  }
+
+  public void setNextReader(AtomicReaderContext context) throws IOException {
+    this.docBase = context.docBase;
+    delegate.setNextReader(context);
+  }
+
+  public boolean acceptsDocsOutOfOrder() {
+    return delegate.acceptsDocsOutOfOrder();
+  }
+
+  public int getMatches() {
+    return matches;
+  }
+
+  /**
+   * Returns the delegate collector
+   *
+   * @return the delegate collector
+   */
+  public Collector getDelegate() {
+    return delegate;
+  }
+}

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/LoadAdminUiServlet.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/LoadAdminUiServlet.java?rev=1305339&r1=1305338&r2=1305339&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/LoadAdminUiServlet.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/LoadAdminUiServlet.java Mon Mar 26 12:58:58 2012
@@ -1,82 +1,82 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.solr.servlet;
-
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.PrintWriter;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.StringEscapeUtils;
-import org.apache.solr.core.CoreContainer;
-
-
-/**
- * A simple servlet to load the Solr Admin UI
- * 
- * @since solr 4.0
- */
-public final class LoadAdminUiServlet extends HttpServlet {
-
-  @Override
-  public void doGet(HttpServletRequest request,
-                    HttpServletResponse response)
-      throws IOException, ServletException {
-    response.setCharacterEncoding("UTF-8");
-    response.setContentType("text/html");
-
-    PrintWriter out = response.getWriter();
-    InputStream in = getServletContext().getResourceAsStream("/admin.html");
-    if(in != null) {
-      try {
-        // This attribute is set by the SolrDispatchFilter
-        CoreContainer cores = (CoreContainer) request.getAttribute("org.apache.solr.CoreContainer");
-
-        String html = IOUtils.toString(in, "UTF-8");
-
-        String[] search = new String[] { 
-            "${contextPath}", 
-            "${adminPath}" 
-        };
-        String[] replace = new String[] {
-            StringEscapeUtils.escapeJavaScript(request.getContextPath()),
-            StringEscapeUtils.escapeJavaScript(cores.getAdminPath())
-        };
-        
-        out.println( StringUtils.replaceEach(html, search, replace) );
-      } finally {
-        IOUtils.closeQuietly(in);
-      }
-    } else {
-      out.println("solr");
-    }
-  }
-
-  @Override
-  public void doPost(HttpServletRequest request,
-                     HttpServletResponse response)
-      throws IOException, ServletException {
-    doGet(request, response);
-  }
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.servlet;
+
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.solr.core.CoreContainer;
+
+
+/**
+ * A simple servlet to load the Solr Admin UI
+ * 
+ * @since solr 4.0
+ */
+public final class LoadAdminUiServlet extends HttpServlet {
+
+  @Override
+  public void doGet(HttpServletRequest request,
+                    HttpServletResponse response)
+      throws IOException, ServletException {
+    response.setCharacterEncoding("UTF-8");
+    response.setContentType("text/html");
+
+    PrintWriter out = response.getWriter();
+    InputStream in = getServletContext().getResourceAsStream("/admin.html");
+    if(in != null) {
+      try {
+        // This attribute is set by the SolrDispatchFilter
+        CoreContainer cores = (CoreContainer) request.getAttribute("org.apache.solr.CoreContainer");
+
+        String html = IOUtils.toString(in, "UTF-8");
+
+        String[] search = new String[] { 
+            "${contextPath}", 
+            "${adminPath}" 
+        };
+        String[] replace = new String[] {
+            StringEscapeUtils.escapeJavaScript(request.getContextPath()),
+            StringEscapeUtils.escapeJavaScript(cores.getAdminPath())
+        };
+        
+        out.println( StringUtils.replaceEach(html, search, replace) );
+      } finally {
+        IOUtils.closeQuietly(in);
+      }
+    } else {
+      out.println("solr");
+    }
+  }
+
+  @Override
+  public void doPost(HttpServletRequest request,
+                     HttpServletResponse response)
+      throws IOException, ServletException {
+    doGet(request, response);
+  }
+}

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/ZookeeperInfoServlet.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/ZookeeperInfoServlet.java?rev=1305339&r1=1305338&r2=1305339&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/ZookeeperInfoServlet.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/servlet/ZookeeperInfoServlet.java Mon Mar 26 12:58:58 2012
@@ -1,409 +1,409 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.solr.servlet;
-
-import org.apache.lucene.util.BytesRef;
-import org.apache.noggit.CharArr;
-import org.apache.noggit.JSONWriter;
-import org.apache.solr.cloud.ZkController;
-import org.apache.solr.common.cloud.SolrZkClient;
-import org.apache.solr.core.CoreContainer;
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.data.Stat;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.net.URLEncoder;
-import java.util.Date;
-import java.util.List;
-import java.util.concurrent.TimeoutException;
-
-
-/**
- * Zookeeper Info
- *
- * @since solr 4.0
- */
-public final class ZookeeperInfoServlet extends HttpServlet {
-  static final Logger log = LoggerFactory.getLogger(ZookeeperInfoServlet.class);
-
-  @Override
-  public void init() throws ServletException {
-  }
-
-  @Override
-  public void doGet(HttpServletRequest request,
-                    HttpServletResponse response)
-      throws IOException, ServletException {
-    response.setCharacterEncoding("UTF-8");
-    response.setContentType("application/json");
-
-    // This attribute is set by the SolrDispatchFilter
-    CoreContainer cores = (CoreContainer) request.getAttribute("org.apache.solr.CoreContainer");
-
-    String path = request.getParameter("path");
-    String addr = request.getParameter("addr");
-
-    if (addr != null && addr.length() == 0) {
-      addr = null;
-    }
-
-    String detailS = request.getParameter("detail");
-    boolean detail = detailS != null && detailS.equals("true");
-
-    String dumpS = request.getParameter("dump");
-    boolean dump = dumpS != null && dumpS.equals("true");
-
-    PrintWriter out = response.getWriter();
-
-
-    ZKPrinter printer = new ZKPrinter(response, out, cores.getZkController(), addr);
-    printer.detail = detail;
-    printer.dump = dump;
-
-    try {
-      printer.print(path);
-    } finally {
-      printer.close();
-    }
-  }
-
-  @Override
-  public void doPost(HttpServletRequest request,
-                     HttpServletResponse response)
-      throws IOException, ServletException {
-    doGet(request, response);
-  }
-
-
-  //--------------------------------------------------------------------------------------
-  //
-  //--------------------------------------------------------------------------------------
-
-  static class ZKPrinter {
-    static boolean FULLPATH_DEFAULT = false;
-
-    boolean indent = true;
-    boolean fullpath = FULLPATH_DEFAULT;
-    boolean detail = false;
-    boolean dump = false;
-
-    String addr; // the address passed to us
-    String keeperAddr; // the address we're connected to
-
-    boolean doClose;  // close the client after done if we opened it
-
-    final HttpServletResponse response;
-    final PrintWriter out;
-    SolrZkClient zkClient;
-
-    int level;
-    int maxData = 95;
-
-    public ZKPrinter(HttpServletResponse response, PrintWriter out, ZkController controller, String addr) throws IOException {
-      this.response = response;
-      this.out = out;
-      this.addr = addr;
-
-      if (addr == null) {
-        if (controller != null) {
-          // this core is zk enabled
-          keeperAddr = controller.getZkServerAddress();
-          zkClient = controller.getZkClient();
-          if (zkClient != null && zkClient.isConnected()) {
-            return;
-          } else {
-            // try a different client with this address
-            addr = keeperAddr;
-          }
-        }
-      }
-
-      keeperAddr = addr;
-      if (addr == null) {
-        writeError(404, "Zookeeper is not configured for this Solr Core. Please try connecting to an alternate zookeeper address.");
-        return;
-      }
-
-      try {
-        zkClient = new SolrZkClient(addr, 10000);
-        doClose = true;
-      } catch (TimeoutException e) {
-        writeError(503, "Could not connect to zookeeper at '" + addr + "'\"");
-        zkClient = null;
-        return;
-      } catch (InterruptedException e) {
-        // Restore the interrupted status
-        Thread.currentThread().interrupt();
-        writeError(503, "Could not connect to zookeeper at '" + addr + "'\"");
-        zkClient = null;
-        return;
-      }
-
-    }
-
-    public void close() {
-      try {
-        if (doClose) {
-          zkClient.close();
-        }
-      } catch (InterruptedException e) {
-        // ignore exception on close
-      }
-    }
-
-    // main entry point
-    void print(String path) throws IOException {
-      if (zkClient == null) {
-        return;
-      }
-
-      // normalize path
-      if (path == null) {
-        path = "/";
-      } else {
-        path.trim();
-        if (path.length() == 0) {
-          path = "/";
-        }
-      }
-
-      if (path.endsWith("/") && path.length() > 1) {
-        path = path.substring(0, path.length() - 1);
-      }
-
-      int idx = path.lastIndexOf('/');
-      String parent = idx >= 0 ? path.substring(0, idx) : path;
-      if (parent.length() == 0) {
-        parent = "/";
-      }
-
-      CharArr chars = new CharArr();
-      JSONWriter json = new JSONWriter(chars, 2);
-      json.startObject();
-
-      if (detail) {
-        if (!printZnode(json, path)) {
-          return;
-        }
-        json.writeValueSeparator();
-      }
-
-      json.writeString("tree");
-      json.writeNameSeparator();
-      json.startArray();
-      if (!printTree(json, path)) {
-        return; // there was an error
-      }
-      json.endArray();
-      json.endObject();
-      out.println(chars.toString());
-    }
-
-    void writeError(int code, String msg) {
-      response.setStatus(code);
-
-      CharArr chars = new CharArr();
-      JSONWriter w = new JSONWriter(chars, 2);
-      w.startObject();
-      w.indent();
-      w.writeString("status");
-      w.writeNameSeparator();
-      w.write(code);
-      w.writeValueSeparator();
-      w.indent();
-      w.writeString("error");
-      w.writeNameSeparator();
-      w.writeString(msg);
-      w.endObject();
-
-      out.println(chars.toString());
-    }
-
-
-    boolean printTree(JSONWriter json, String path) throws IOException {
-      String label = path;
-      if (!fullpath) {
-        int idx = path.lastIndexOf('/');
-        label = idx > 0 ? path.substring(idx + 1) : path;
-      }
-      json.startObject();
-      //writeKeyValue(json, "data", label, true );
-      json.writeString("data");
-      json.writeNameSeparator();
-
-      json.startObject();
-      writeKeyValue(json, "title", label, true);
-      json.writeValueSeparator();
-      json.writeString("attr");
-      json.writeNameSeparator();
-      json.startObject();
-      writeKeyValue(json, "href", "zookeeper?detail=true&path=" + URLEncoder.encode(path, "UTF-8"), true);
-      json.endObject();
-      json.endObject();
-
-      Stat stat = new Stat();
-      try {
-        // Trickily, the call to zkClient.getData fills in the stat variable
-        byte[] data = zkClient.getData(path, null, stat, true);
-
-        if (stat.getEphemeralOwner() != 0) {
-          writeKeyValue(json, "ephemeral", true, false);
-          writeKeyValue(json, "version", stat.getVersion(), false);
-        }
-
-        if (dump) {
-          json.writeValueSeparator();
-          printZnode(json, path);
-        }
-
-        /*
-        if (stat.getNumChildren() != 0)
-        {
-          writeKeyValue(json, "children_count",  stat.getNumChildren(), false );
-          out.println(", \"children_count\" : \"" + stat.getNumChildren() + "\"");
-        }
-        */
-
-        //if (stat.getDataLength() != 0)
-        if (data != null) {
-          String str = new BytesRef(data).utf8ToString();
-          //?? writeKeyValue(json, "content", str, false );
-          // Does nothing now, but on the assumption this will be used later we'll leave it in. If it comes out
-          // the catches below need to be restructured.
-        }
-      } catch (IllegalArgumentException e) {
-        // path doesn't exist (must have been removed)
-        writeKeyValue(json, "warning", "(path gone)", false);
-      } catch (KeeperException e) {
-        writeKeyValue(json, "warning", e.toString(), false);
-        log.warn("Keeper Exception", e);
-      } catch (InterruptedException e) {
-        writeKeyValue(json, "warning", e.toString(), false);
-        log.warn("InterruptedException", e);
-      }
-
-      if (stat.getNumChildren() > 0) {
-        json.writeValueSeparator();
-        if (indent) {
-          json.indent();
-        }
-        json.writeString("children");
-        json.writeNameSeparator();
-        json.startArray();
-
-        try {
-          List<String> children = zkClient.getChildren(path, null, true);
-          java.util.Collections.sort(children);
-
-          boolean first = true;
-          for (String child : children) {
-            if (!first) {
-              json.writeValueSeparator();
-            }
-
-            String childPath = path + (path.endsWith("/") ? "" : "/") + child;
-            if (!printTree(json, childPath)) {
-              return false;
-            }
-            first = false;
-          }
-        } catch (KeeperException e) {
-          writeError(500, e.toString());
-          return false;
-        } catch (InterruptedException e) {
-          writeError(500, e.toString());
-          return false;
-        } catch (IllegalArgumentException e) {
-          // path doesn't exist (must have been removed)
-          json.writeString("(children gone)");
-        }
-
-        json.endArray();
-      }
-
-      json.endObject();
-      return true;
-    }
-
-    String time(long ms) {
-      return (new Date(ms)).toString() + " (" + ms + ")";
-    }
-
-    public void writeKeyValue(JSONWriter json, String k, Object v, boolean isFirst) {
-      if (!isFirst) {
-        json.writeValueSeparator();
-      }
-      if (indent) {
-        json.indent();
-      }
-      json.writeString(k);
-      json.writeNameSeparator();
-      json.write(v);
-    }
-
-    boolean printZnode(JSONWriter json, String path) throws IOException {
-      try {
-        Stat stat = new Stat();
-        // Trickily, the call to zkClient.getData fills in the stat variable
-        byte[] data = zkClient.getData(path, null, stat, true);
-
-        json.writeString("znode");
-        json.writeNameSeparator();
-        json.startObject();
-
-        writeKeyValue(json, "path", path, true);
-
-        json.writeValueSeparator();
-        json.writeString("prop");
-        json.writeNameSeparator();
-        json.startObject();
-        writeKeyValue(json, "version", stat.getVersion(), true);
-        writeKeyValue(json, "aversion", stat.getAversion(), false);
-        writeKeyValue(json, "children_count", stat.getNumChildren(), false);
-        writeKeyValue(json, "ctime", time(stat.getCtime()), false);
-        writeKeyValue(json, "cversion", stat.getCversion(), false);
-        writeKeyValue(json, "czxid", stat.getCzxid(), false);
-        writeKeyValue(json, "dataLength", stat.getDataLength(), false);
-        writeKeyValue(json, "ephemeralOwner", stat.getEphemeralOwner(), false);
-        writeKeyValue(json, "mtime", time(stat.getMtime()), false);
-        writeKeyValue(json, "mzxid", stat.getMzxid(), false);
-        writeKeyValue(json, "pzxid", stat.getPzxid(), false);
-        json.endObject();
-
-        if (data != null) {
-          writeKeyValue(json, "data", new BytesRef(data).utf8ToString(), false);
-        }
-        json.endObject();
-      } catch (KeeperException e) {
-        writeError(500, e.toString());
-        return false;
-      } catch (InterruptedException e) {
-        writeError(500, e.toString());
-        return false;
-      }
-      return true;
-    }
-  }
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.servlet;
+
+import org.apache.lucene.util.BytesRef;
+import org.apache.noggit.CharArr;
+import org.apache.noggit.JSONWriter;
+import org.apache.solr.cloud.ZkController;
+import org.apache.solr.common.cloud.SolrZkClient;
+import org.apache.solr.core.CoreContainer;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.data.Stat;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.net.URLEncoder;
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.TimeoutException;
+
+
+/**
+ * Zookeeper Info
+ *
+ * @since solr 4.0
+ */
+public final class ZookeeperInfoServlet extends HttpServlet {
+  static final Logger log = LoggerFactory.getLogger(ZookeeperInfoServlet.class);
+
+  @Override
+  public void init() throws ServletException {
+  }
+
+  @Override
+  public void doGet(HttpServletRequest request,
+                    HttpServletResponse response)
+      throws IOException, ServletException {
+    response.setCharacterEncoding("UTF-8");
+    response.setContentType("application/json");
+
+    // This attribute is set by the SolrDispatchFilter
+    CoreContainer cores = (CoreContainer) request.getAttribute("org.apache.solr.CoreContainer");
+
+    String path = request.getParameter("path");
+    String addr = request.getParameter("addr");
+
+    if (addr != null && addr.length() == 0) {
+      addr = null;
+    }
+
+    String detailS = request.getParameter("detail");
+    boolean detail = detailS != null && detailS.equals("true");
+
+    String dumpS = request.getParameter("dump");
+    boolean dump = dumpS != null && dumpS.equals("true");
+
+    PrintWriter out = response.getWriter();
+
+
+    ZKPrinter printer = new ZKPrinter(response, out, cores.getZkController(), addr);
+    printer.detail = detail;
+    printer.dump = dump;
+
+    try {
+      printer.print(path);
+    } finally {
+      printer.close();
+    }
+  }
+
+  @Override
+  public void doPost(HttpServletRequest request,
+                     HttpServletResponse response)
+      throws IOException, ServletException {
+    doGet(request, response);
+  }
+
+
+  //--------------------------------------------------------------------------------------
+  //
+  //--------------------------------------------------------------------------------------
+
+  static class ZKPrinter {
+    static boolean FULLPATH_DEFAULT = false;
+
+    boolean indent = true;
+    boolean fullpath = FULLPATH_DEFAULT;
+    boolean detail = false;
+    boolean dump = false;
+
+    String addr; // the address passed to us
+    String keeperAddr; // the address we're connected to
+
+    boolean doClose;  // close the client after done if we opened it
+
+    final HttpServletResponse response;
+    final PrintWriter out;
+    SolrZkClient zkClient;
+
+    int level;
+    int maxData = 95;
+
+    public ZKPrinter(HttpServletResponse response, PrintWriter out, ZkController controller, String addr) throws IOException {
+      this.response = response;
+      this.out = out;
+      this.addr = addr;
+
+      if (addr == null) {
+        if (controller != null) {
+          // this core is zk enabled
+          keeperAddr = controller.getZkServerAddress();
+          zkClient = controller.getZkClient();
+          if (zkClient != null && zkClient.isConnected()) {
+            return;
+          } else {
+            // try a different client with this address
+            addr = keeperAddr;
+          }
+        }
+      }
+
+      keeperAddr = addr;
+      if (addr == null) {
+        writeError(404, "Zookeeper is not configured for this Solr Core. Please try connecting to an alternate zookeeper address.");
+        return;
+      }
+
+      try {
+        zkClient = new SolrZkClient(addr, 10000);
+        doClose = true;
+      } catch (TimeoutException e) {
+        writeError(503, "Could not connect to zookeeper at '" + addr + "'\"");
+        zkClient = null;
+        return;
+      } catch (InterruptedException e) {
+        // Restore the interrupted status
+        Thread.currentThread().interrupt();
+        writeError(503, "Could not connect to zookeeper at '" + addr + "'\"");
+        zkClient = null;
+        return;
+      }
+
+    }
+
+    public void close() {
+      try {
+        if (doClose) {
+          zkClient.close();
+        }
+      } catch (InterruptedException e) {
+        // ignore exception on close
+      }
+    }
+
+    // main entry point
+    void print(String path) throws IOException {
+      if (zkClient == null) {
+        return;
+      }
+
+      // normalize path
+      if (path == null) {
+        path = "/";
+      } else {
+        path.trim();
+        if (path.length() == 0) {
+          path = "/";
+        }
+      }
+
+      if (path.endsWith("/") && path.length() > 1) {
+        path = path.substring(0, path.length() - 1);
+      }
+
+      int idx = path.lastIndexOf('/');
+      String parent = idx >= 0 ? path.substring(0, idx) : path;
+      if (parent.length() == 0) {
+        parent = "/";
+      }
+
+      CharArr chars = new CharArr();
+      JSONWriter json = new JSONWriter(chars, 2);
+      json.startObject();
+
+      if (detail) {
+        if (!printZnode(json, path)) {
+          return;
+        }
+        json.writeValueSeparator();
+      }
+
+      json.writeString("tree");
+      json.writeNameSeparator();
+      json.startArray();
+      if (!printTree(json, path)) {
+        return; // there was an error
+      }
+      json.endArray();
+      json.endObject();
+      out.println(chars.toString());
+    }
+
+    void writeError(int code, String msg) {
+      response.setStatus(code);
+
+      CharArr chars = new CharArr();
+      JSONWriter w = new JSONWriter(chars, 2);
+      w.startObject();
+      w.indent();
+      w.writeString("status");
+      w.writeNameSeparator();
+      w.write(code);
+      w.writeValueSeparator();
+      w.indent();
+      w.writeString("error");
+      w.writeNameSeparator();
+      w.writeString(msg);
+      w.endObject();
+
+      out.println(chars.toString());
+    }
+
+
+    boolean printTree(JSONWriter json, String path) throws IOException {
+      String label = path;
+      if (!fullpath) {
+        int idx = path.lastIndexOf('/');
+        label = idx > 0 ? path.substring(idx + 1) : path;
+      }
+      json.startObject();
+      //writeKeyValue(json, "data", label, true );
+      json.writeString("data");
+      json.writeNameSeparator();
+
+      json.startObject();
+      writeKeyValue(json, "title", label, true);
+      json.writeValueSeparator();
+      json.writeString("attr");
+      json.writeNameSeparator();
+      json.startObject();
+      writeKeyValue(json, "href", "zookeeper?detail=true&path=" + URLEncoder.encode(path, "UTF-8"), true);
+      json.endObject();
+      json.endObject();
+
+      Stat stat = new Stat();
+      try {
+        // Trickily, the call to zkClient.getData fills in the stat variable
+        byte[] data = zkClient.getData(path, null, stat, true);
+
+        if (stat.getEphemeralOwner() != 0) {
+          writeKeyValue(json, "ephemeral", true, false);
+          writeKeyValue(json, "version", stat.getVersion(), false);
+        }
+
+        if (dump) {
+          json.writeValueSeparator();
+          printZnode(json, path);
+        }
+
+        /*
+        if (stat.getNumChildren() != 0)
+        {
+          writeKeyValue(json, "children_count",  stat.getNumChildren(), false );
+          out.println(", \"children_count\" : \"" + stat.getNumChildren() + "\"");
+        }
+        */
+
+        //if (stat.getDataLength() != 0)
+        if (data != null) {
+          String str = new BytesRef(data).utf8ToString();
+          //?? writeKeyValue(json, "content", str, false );
+          // Does nothing now, but on the assumption this will be used later we'll leave it in. If it comes out
+          // the catches below need to be restructured.
+        }
+      } catch (IllegalArgumentException e) {
+        // path doesn't exist (must have been removed)
+        writeKeyValue(json, "warning", "(path gone)", false);
+      } catch (KeeperException e) {
+        writeKeyValue(json, "warning", e.toString(), false);
+        log.warn("Keeper Exception", e);
+      } catch (InterruptedException e) {
+        writeKeyValue(json, "warning", e.toString(), false);
+        log.warn("InterruptedException", e);
+      }
+
+      if (stat.getNumChildren() > 0) {
+        json.writeValueSeparator();
+        if (indent) {
+          json.indent();
+        }
+        json.writeString("children");
+        json.writeNameSeparator();
+        json.startArray();
+
+        try {
+          List<String> children = zkClient.getChildren(path, null, true);
+          java.util.Collections.sort(children);
+
+          boolean first = true;
+          for (String child : children) {
+            if (!first) {
+              json.writeValueSeparator();
+            }
+
+            String childPath = path + (path.endsWith("/") ? "" : "/") + child;
+            if (!printTree(json, childPath)) {
+              return false;
+            }
+            first = false;
+          }
+        } catch (KeeperException e) {
+          writeError(500, e.toString());
+          return false;
+        } catch (InterruptedException e) {
+          writeError(500, e.toString());
+          return false;
+        } catch (IllegalArgumentException e) {
+          // path doesn't exist (must have been removed)
+          json.writeString("(children gone)");
+        }
+
+        json.endArray();
+      }
+
+      json.endObject();
+      return true;
+    }
+
+    String time(long ms) {
+      return (new Date(ms)).toString() + " (" + ms + ")";
+    }
+
+    public void writeKeyValue(JSONWriter json, String k, Object v, boolean isFirst) {
+      if (!isFirst) {
+        json.writeValueSeparator();
+      }
+      if (indent) {
+        json.indent();
+      }
+      json.writeString(k);
+      json.writeNameSeparator();
+      json.write(v);
+    }
+
+    boolean printZnode(JSONWriter json, String path) throws IOException {
+      try {
+        Stat stat = new Stat();
+        // Trickily, the call to zkClient.getData fills in the stat variable
+        byte[] data = zkClient.getData(path, null, stat, true);
+
+        json.writeString("znode");
+        json.writeNameSeparator();
+        json.startObject();
+
+        writeKeyValue(json, "path", path, true);
+
+        json.writeValueSeparator();
+        json.writeString("prop");
+        json.writeNameSeparator();
+        json.startObject();
+        writeKeyValue(json, "version", stat.getVersion(), true);
+        writeKeyValue(json, "aversion", stat.getAversion(), false);
+        writeKeyValue(json, "children_count", stat.getNumChildren(), false);
+        writeKeyValue(json, "ctime", time(stat.getCtime()), false);
+        writeKeyValue(json, "cversion", stat.getCversion(), false);
+        writeKeyValue(json, "czxid", stat.getCzxid(), false);
+        writeKeyValue(json, "dataLength", stat.getDataLength(), false);
+        writeKeyValue(json, "ephemeralOwner", stat.getEphemeralOwner(), false);
+        writeKeyValue(json, "mtime", time(stat.getMtime()), false);
+        writeKeyValue(json, "mzxid", stat.getMzxid(), false);
+        writeKeyValue(json, "pzxid", stat.getPzxid(), false);
+        json.endObject();
+
+        if (data != null) {
+          writeKeyValue(json, "data", new BytesRef(data).utf8ToString(), false);
+        }
+        json.endObject();
+      } catch (KeeperException e) {
+        writeError(500, e.toString());
+        return false;
+      } catch (InterruptedException e) {
+        writeError(500, e.toString());
+        return false;
+      }
+      return true;
+    }
+  }
+}

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestPseudoReturnFields.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestPseudoReturnFields.java?rev=1305339&r1=1305338&r2=1305339&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestPseudoReturnFields.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestPseudoReturnFields.java Mon Mar 26 12:58:58 2012
@@ -1,456 +1,456 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.solr.search;
-
-import org.apache.solr.SolrTestCaseJ4;
-
-import org.apache.commons.lang.StringUtils;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-
-public class TestPseudoReturnFields extends SolrTestCaseJ4 {
-
-  // :TODO: datatypes produced by the functions used may change
-
-  /**
-   * values of the fl param that mean all real fields
-   */
-  private static String[] ALL_REAL_FIELDS = new String[] { "", "*" };
-
-  /**
-   * values of the fl param that mean all real fields and score
-   */
-  private static String[] SCORE_AND_REAL_FIELDS = new String[] { 
-    "score,*", "*,score"
-  };
-
-  @BeforeClass
-  public static void beforeTests() throws Exception {
-    initCore("solrconfig.xml","schema12.xml");
-
-
-    assertU(adoc("id", "42", "val_i", "1", "ssto", "X", "subject", "aaa"));
-    assertU(adoc("id", "43", "val_i", "9", "ssto", "X", "subject", "bbb"));
-    assertU(adoc("id", "44", "val_i", "4", "ssto", "X", "subject", "aaa"));
-    assertU(adoc("id", "45", "val_i", "6", "ssto", "X", "subject", "aaa"));
-    assertU(adoc("id", "46", "val_i", "3", "ssto", "X", "subject", "ggg"));
-    assertU(commit());
-  }
-  
-  @Test
-  public void testAllRealFields() throws Exception {
-
-    for (String fl : ALL_REAL_FIELDS) {
-      assertQ("fl="+fl+" ... all real fields",
-              req("q","*:*", "rows", "1", "fl",fl)
-              ,"//result[@numFound='5']"
-              ,"//result/doc/str[@name='id']"
-              ,"//result/doc/int[@name='val_i']"
-              ,"//result/doc/str[@name='ssto']"
-              ,"//result/doc/str[@name='subject']"
-              
-              ,"//result/doc[count(*)=4]"
-              );
-    }
-  }
-
-  @Test
-  public void testScoreAndAllRealFields() throws Exception {
-
-    for (String fl : SCORE_AND_REAL_FIELDS) {
-      assertQ("fl="+fl+" ... score and real fields",
-              req("q","*:*", "rows", "1", "fl",fl)
-              ,"//result[@numFound='5']"
-              ,"//result/doc/str[@name='id']"
-              ,"//result/doc/int[@name='val_i']"
-              ,"//result/doc/str[@name='ssto']"
-              ,"//result/doc/str[@name='subject']"
-              ,"//result/doc/float[@name='score']"
-              
-              ,"//result/doc[count(*)=5]"
-              );
-    }
-  }
-
-  @Test
-  public void testScoreAndExplicitRealFields() throws Exception {
-
-    assertQ("fl=score,val_i",
-            req("q","*:*", "rows", "1", "fl","score,val_i")
-            ,"//result[@numFound='5']"
-            ,"//result/doc/int[@name='val_i']"
-            ,"//result/doc/float[@name='score']"
-            
-            ,"//result/doc[count(*)=2]"
-            );
-    assertQ("fl=score&fl=val_i",
-            req("q","*:*", "rows", "1", "fl","score","fl","val_i")
-            ,"//result[@numFound='5']"
-            ,"//result/doc/int[@name='val_i']"
-            ,"//result/doc/float[@name='score']"
-            
-            ,"//result/doc[count(*)=2]"
-            );
-
-    assertQ("fl=val_i",
-            req("q","*:*", "rows", "1", "fl","val_i")
-            ,"//result[@numFound='5']"
-            ,"//result/doc/int[@name='val_i']"
-            
-            ,"//result/doc[count(*)=1]"
-            );
-  }
-
-  @Test
-  public void testFunctions() throws Exception {
-    assertQ("fl=log(val_i)",
-            req("q","*:*", "rows", "1", "fl","log(val_i)")
-            ,"//result[@numFound='5']"
-            ,"//result/doc/double[@name='log(val_i)']"
-            
-            ,"//result/doc[count(*)=1]"
-            );
-
-    assertQ("fl=log(val_i),abs(val_i)",
-            req("q","*:*", "rows", "1", "fl","log(val_i),abs(val_i)")
-            ,"//result[@numFound='5']"
-            ,"//result/doc/double[@name='log(val_i)']"
-            ,"//result/doc/float[@name='abs(val_i)']"
-            
-            ,"//result/doc[count(*)=2]"
-            );
-    assertQ("fl=log(val_i)&fl=abs(val_i)",
-            req("q","*:*", "rows", "1", "fl","log(val_i)","fl","abs(val_i)")
-            ,"//result[@numFound='5']"
-            ,"//result/doc/double[@name='log(val_i)']"
-            ,"//result/doc/float[@name='abs(val_i)']"
-            
-            ,"//result/doc[count(*)=2]"
-            );
-  }
-
-  @Test
-  public void testFunctionsAndExplicit() throws Exception {
-    assertQ("fl=log(val_i),val_i",
-            req("q","*:*", "rows", "1", "fl","log(val_i),val_i")
-            ,"//result[@numFound='5']"
-            ,"//result/doc/double[@name='log(val_i)']"
-            ,"//result/doc/int[@name='val_i']"
-
-            ,"//result/doc[count(*)=2]"
-            );
-
-    assertQ("fl=log(val_i)&fl=val_i",
-            req("q","*:*", "rows", "1", "fl","log(val_i)","fl","val_i")
-            ,"//result[@numFound='5']"
-            ,"//result/doc/double[@name='log(val_i)']"
-            ,"//result/doc/int[@name='val_i']"
-            
-            ,"//result/doc[count(*)=2]"
-            );
-  }
-
-  @Test
-  public void testFunctionsAndScore() throws Exception {
-
-    assertQ("fl=log(val_i),score",
-            req("q","*:*", "rows", "1", "fl","log(val_i),score")
-            ,"//result[@numFound='5']"
-            ,"//result/doc/float[@name='score']"
-            ,"//result/doc/double[@name='log(val_i)']"
-            
-            ,"//result/doc[count(*)=2]"
-            );
-    assertQ("fl=log(val_i)&fl=score",
-            req("q","*:*", "rows", "1", "fl","log(val_i)","fl","score")
-            ,"//result[@numFound='5']"
-            ,"//result/doc/float[@name='score']"
-            ,"//result/doc/double[@name='log(val_i)']"
-            
-            ,"//result/doc[count(*)=2]"
-            );
-
-    assertQ("fl=score,log(val_i),abs(val_i)",
-            req("q","*:*", "rows", "1", 
-                "fl","score,log(val_i),abs(val_i)")
-            ,"//result[@numFound='5']"
-            ,"//result/doc/float[@name='score']"
-            ,"//result/doc/double[@name='log(val_i)']"
-            ,"//result/doc/float[@name='abs(val_i)']"
-            
-            ,"//result/doc[count(*)=3]"
-            );
-    assertQ("fl=score&fl=log(val_i)&fl=abs(val_i)",
-            req("q","*:*", "rows", "1", 
-                "fl","score","fl","log(val_i)","fl","abs(val_i)")
-            ,"//result[@numFound='5']"
-            ,"//result/doc/float[@name='score']"
-            ,"//result/doc/double[@name='log(val_i)']"
-            ,"//result/doc/float[@name='abs(val_i)']"
-            
-            ,"//result/doc[count(*)=3]"
-            );
-    
-  }
-
-  @Test
-  public void testGlobs() throws Exception {
-    assertQ("fl=val_*",
-            req("q","*:*", "rows", "1", "fl","val_*")
-            ,"//result[@numFound='5']"
-            ,"//result/doc/int[@name='val_i']"
-            
-            ,"//result/doc[count(*)=1]"
-            );
-
-    assertQ("fl=val_*,subj*",
-            req("q","*:*", "rows", "1", "fl","val_*,subj*")
-            ,"//result[@numFound='5']"
-            ,"//result/doc/int[@name='val_i']"
-            ,"//result/doc/str[@name='subject']"
-            
-            ,"//result/doc[count(*)=2]"
-            );
-    assertQ("fl=val_*&fl=subj*",
-            req("q","*:*", "rows", "1", "fl","val_*","fl","subj*")
-            ,"//result[@numFound='5']"
-            ,"//result/doc/int[@name='val_i']"
-            ,"//result/doc/str[@name='subject']"
-            
-            ,"//result/doc[count(*)=2]"
-            );
-  }
-
-  @Test
-  public void testGlobsAndExplicit() throws Exception {
-    assertQ("fl=val_*,id",
-            req("q","*:*", "rows", "1", "fl","val_*,id")
-            ,"//result[@numFound='5']"
-            ,"//result/doc/int[@name='val_i']"
-            ,"//result/doc/str[@name='id']"
-            
-            ,"//result/doc[count(*)=2]"
-            );
-
-    assertQ("fl=val_*,subj*,id",
-            req("q","*:*", "rows", "1", "fl","val_*,subj*,id")
-            ,"//result[@numFound='5']"
-            ,"//result/doc/int[@name='val_i']"
-            ,"//result/doc/str[@name='subject']"
-            ,"//result/doc/str[@name='id']"
-            
-            ,"//result/doc[count(*)=3]"
-            );
-    assertQ("fl=val_*&fl=subj*&fl=id",
-            req("q","*:*", "rows", "1", "fl","val_*","fl","subj*","fl","id")
-            ,"//result[@numFound='5']"
-            ,"//result/doc/int[@name='val_i']"
-            ,"//result/doc/str[@name='subject']"
-            ,"//result/doc/str[@name='id']"
-            
-            ,"//result/doc[count(*)=3]"
-            );
-  }
-
-  @Test
-  public void testGlobsAndScore() throws Exception {
-    assertQ("fl=val_*,score",
-            req("q","*:*", "rows", "1", "fl","val_*,score", "indent", "true")
-            ,"//result[@numFound='5']"
-            ,"//result/doc/float[@name='score']"
-            ,"//result/doc/int[@name='val_i']"
-            
-            ,"//result/doc[count(*)=2]"
-            );
-
-    assertQ("fl=val_*,subj*,score",
-            req("q","*:*", "rows", "1", "fl","val_*,subj*,score")
-            ,"//result[@numFound='5']"
-            ,"//result/doc/float[@name='score']"
-            ,"//result/doc/int[@name='val_i']"
-            ,"//result/doc/str[@name='subject']"
-            
-            ,"//result/doc[count(*)=3]"
-            );
-    assertQ("fl=val_*&fl=subj*&fl=score",
-            req("q","*:*", "rows", "1", 
-                "fl","val_*","fl","subj*","fl","score")
-            ,"//result[@numFound='5']"
-            ,"//result/doc/float[@name='score']"
-            ,"//result/doc/int[@name='val_i']"
-            ,"//result/doc/str[@name='subject']"
-            
-            ,"//result/doc[count(*)=3]"
-            );
-
-    
-  }
-
-  @Test
-  public void testAugmenters() throws Exception {
-    assertQ("fl=[docid]",
-            req("q","*:*", "rows", "1", "fl","[docid]")
-            ,"//result[@numFound='5']"
-            ,"//result/doc/int[@name='[docid]']"
-            
-            ,"//result/doc[count(*)=1]"
-            );
-
-    assertQ("fl=[docid],[explain]",
-            req("q","*:*", "rows", "1", "fl","[docid],[explain]")
-            ,"//result[@numFound='5']"
-            ,"//result/doc/int[@name='[docid]']"
-            ,"//result/doc/str[@name='[explain]']"
-            
-            ,"//result/doc[count(*)=2]"
-            );
-    assertQ("fl=[docid]&fl=[explain]",
-            req("q","*:*", "rows", "1", "fl","[docid]","fl","[explain]")
-            ,"//result[@numFound='5']"
-            ,"//result/doc/int[@name='[docid]']"
-            ,"//result/doc/str[@name='[explain]']"
-            
-            ,"//result/doc[count(*)=2]"
-            );
-  }
-
-  @Test
-  public void testAugmentersAndExplicit() throws Exception {
-    assertQ("fl=[docid],id",
-            req("q","*:*", "rows", "1", 
-                "fl","[docid],id")
-            ,"//result[@numFound='5']"
-            ,"//result/doc/int[@name='[docid]']"
-            ,"//result/doc/str[@name='id']"
-            
-            ,"//result/doc[count(*)=2]"
-            );
-
-    assertQ("fl=[docid],[explain],id",
-            req("q","*:*", "rows", "1", 
-                "fl","[docid],[explain],id")
-            ,"//result[@numFound='5']"
-            ,"//result/doc/int[@name='[docid]']"
-            ,"//result/doc/str[@name='[explain]']"
-            ,"//result/doc/str[@name='id']"
-            
-            ,"//result/doc[count(*)=3]"
-            );
-    assertQ("fl=[docid]&fl=[explain]&fl=id",
-            req("q","*:*", "rows", "1", 
-                "fl","[docid]","fl","[explain]","fl","id")
-            ,"//result[@numFound='5']"
-            ,"//result/doc/int[@name='[docid]']"
-            ,"//result/doc/str[@name='[explain]']"
-            ,"//result/doc/str[@name='id']"
-            
-            ,"//result/doc[count(*)=3]"
-            );
-  }
-
-  @Test
-  public void testAugmentersAndScore() throws Exception {
-    assertQ("fl=[docid],score",
-            req("q","*:*", "rows", "1",
-                "fl","[docid],score")
-            ,"//result[@numFound='5']"
-            ,"//result/doc/float[@name='score']"
-            ,"//result/doc/int[@name='[docid]']"
-            
-            ,"//result/doc[count(*)=2]"
-            );
-
-    assertQ("fl=[docid],[explain],score",
-            req("q","*:*", "rows", "1",
-                "fl","[docid],[explain],score")
-            ,"//result[@numFound='5']"
-            ,"//result/doc/float[@name='score']"
-            ,"//result/doc/int[@name='[docid]']"
-            ,"//result/doc/str[@name='[explain]']"
-            
-            ,"//result/doc[count(*)=3]"
-            );
-    assertQ("fl=[docid]&fl=[explain]&fl=score",
-            req("q","*:*", "rows", "1", 
-                "fl","[docid]","fl","[explain]","fl","score")
-            ,"//result[@numFound='5']"
-            ,"//result/doc/float[@name='score']"
-            ,"//result/doc/int[@name='[docid]']"
-            ,"//result/doc/str[@name='[explain]']"
-            
-            ,"//result/doc[count(*)=3]"
-            );
-  }
-
-  @Test
-  public void testAugmentersGlobsExplicitAndScoreOhMy() throws Exception {
-
-    // NOTE: 'ssto' is the missing one
-    final List<String> fl = Arrays.asList
-      ("id","[docid]","[explain]","score","val_*","subj*");
-    
-    final int iters = atLeast(random, 10);
-    for (int i = 0; i< iters; i++) {
-      
-      Collections.shuffle(fl, random);
-
-      final String singleFl = StringUtils.join(fl.toArray(),',');
-      assertQ("fl=" + singleFl,
-              req("q","*:*", "rows", "1","fl",singleFl)
-              ,"//result[@numFound='5']"
-              ,"//result/doc/str[@name='id']"
-              ,"//result/doc/float[@name='score']"
-              ,"//result/doc/str[@name='subject']"
-              ,"//result/doc/int[@name='val_i']"
-              ,"//result/doc/int[@name='[docid]']"
-              ,"//result/doc/str[@name='[explain]']"
-              
-              ,"//result/doc[count(*)=6]"
-              );
-
-      final List<String> params = new ArrayList<String>((fl.size()*2) + 4);
-      final StringBuilder info = new StringBuilder();
-      params.addAll(Arrays.asList("q","*:*", "rows", "1"));
-      for (String item : fl) {
-        params.add("fl");
-        params.add(item);
-        info.append("&fl=").append(item);
-      }
-      
-      assertQ(info.toString(),
-              req((String[])params.toArray(new String[0]))
-              ,"//result[@numFound='5']"
-              ,"//result/doc/str[@name='id']"
-              ,"//result/doc/float[@name='score']"
-              ,"//result/doc/str[@name='subject']"
-              ,"//result/doc/int[@name='val_i']"
-              ,"//result/doc/int[@name='[docid]']"
-              ,"//result/doc/str[@name='[explain]']"
-              
-              ,"//result/doc[count(*)=6]"
-              );
-
-    }
-  }
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.search;
+
+import org.apache.solr.SolrTestCaseJ4;
+
+import org.apache.commons.lang.StringUtils;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+
+public class TestPseudoReturnFields extends SolrTestCaseJ4 {
+
+  // :TODO: datatypes produced by the functions used may change
+
+  /**
+   * values of the fl param that mean all real fields
+   */
+  private static String[] ALL_REAL_FIELDS = new String[] { "", "*" };
+
+  /**
+   * values of the fl param that mean all real fields and score
+   */
+  private static String[] SCORE_AND_REAL_FIELDS = new String[] { 
+    "score,*", "*,score"
+  };
+
+  @BeforeClass
+  public static void beforeTests() throws Exception {
+    initCore("solrconfig.xml","schema12.xml");
+
+
+    assertU(adoc("id", "42", "val_i", "1", "ssto", "X", "subject", "aaa"));
+    assertU(adoc("id", "43", "val_i", "9", "ssto", "X", "subject", "bbb"));
+    assertU(adoc("id", "44", "val_i", "4", "ssto", "X", "subject", "aaa"));
+    assertU(adoc("id", "45", "val_i", "6", "ssto", "X", "subject", "aaa"));
+    assertU(adoc("id", "46", "val_i", "3", "ssto", "X", "subject", "ggg"));
+    assertU(commit());
+  }
+  
+  @Test
+  public void testAllRealFields() throws Exception {
+
+    for (String fl : ALL_REAL_FIELDS) {
+      assertQ("fl="+fl+" ... all real fields",
+              req("q","*:*", "rows", "1", "fl",fl)
+              ,"//result[@numFound='5']"
+              ,"//result/doc/str[@name='id']"
+              ,"//result/doc/int[@name='val_i']"
+              ,"//result/doc/str[@name='ssto']"
+              ,"//result/doc/str[@name='subject']"
+              
+              ,"//result/doc[count(*)=4]"
+              );
+    }
+  }
+
+  @Test
+  public void testScoreAndAllRealFields() throws Exception {
+
+    for (String fl : SCORE_AND_REAL_FIELDS) {
+      assertQ("fl="+fl+" ... score and real fields",
+              req("q","*:*", "rows", "1", "fl",fl)
+              ,"//result[@numFound='5']"
+              ,"//result/doc/str[@name='id']"
+              ,"//result/doc/int[@name='val_i']"
+              ,"//result/doc/str[@name='ssto']"
+              ,"//result/doc/str[@name='subject']"
+              ,"//result/doc/float[@name='score']"
+              
+              ,"//result/doc[count(*)=5]"
+              );
+    }
+  }
+
+  @Test
+  public void testScoreAndExplicitRealFields() throws Exception {
+
+    assertQ("fl=score,val_i",
+            req("q","*:*", "rows", "1", "fl","score,val_i")
+            ,"//result[@numFound='5']"
+            ,"//result/doc/int[@name='val_i']"
+            ,"//result/doc/float[@name='score']"
+            
+            ,"//result/doc[count(*)=2]"
+            );
+    assertQ("fl=score&fl=val_i",
+            req("q","*:*", "rows", "1", "fl","score","fl","val_i")
+            ,"//result[@numFound='5']"
+            ,"//result/doc/int[@name='val_i']"
+            ,"//result/doc/float[@name='score']"
+            
+            ,"//result/doc[count(*)=2]"
+            );
+
+    assertQ("fl=val_i",
+            req("q","*:*", "rows", "1", "fl","val_i")
+            ,"//result[@numFound='5']"
+            ,"//result/doc/int[@name='val_i']"
+            
+            ,"//result/doc[count(*)=1]"
+            );
+  }
+
+  @Test
+  public void testFunctions() throws Exception {
+    assertQ("fl=log(val_i)",
+            req("q","*:*", "rows", "1", "fl","log(val_i)")
+            ,"//result[@numFound='5']"
+            ,"//result/doc/double[@name='log(val_i)']"
+            
+            ,"//result/doc[count(*)=1]"
+            );
+
+    assertQ("fl=log(val_i),abs(val_i)",
+            req("q","*:*", "rows", "1", "fl","log(val_i),abs(val_i)")
+            ,"//result[@numFound='5']"
+            ,"//result/doc/double[@name='log(val_i)']"
+            ,"//result/doc/float[@name='abs(val_i)']"
+            
+            ,"//result/doc[count(*)=2]"
+            );
+    assertQ("fl=log(val_i)&fl=abs(val_i)",
+            req("q","*:*", "rows", "1", "fl","log(val_i)","fl","abs(val_i)")
+            ,"//result[@numFound='5']"
+            ,"//result/doc/double[@name='log(val_i)']"
+            ,"//result/doc/float[@name='abs(val_i)']"
+            
+            ,"//result/doc[count(*)=2]"
+            );
+  }
+
+  @Test
+  public void testFunctionsAndExplicit() throws Exception {
+    assertQ("fl=log(val_i),val_i",
+            req("q","*:*", "rows", "1", "fl","log(val_i),val_i")
+            ,"//result[@numFound='5']"
+            ,"//result/doc/double[@name='log(val_i)']"
+            ,"//result/doc/int[@name='val_i']"
+
+            ,"//result/doc[count(*)=2]"
+            );
+
+    assertQ("fl=log(val_i)&fl=val_i",
+            req("q","*:*", "rows", "1", "fl","log(val_i)","fl","val_i")
+            ,"//result[@numFound='5']"
+            ,"//result/doc/double[@name='log(val_i)']"
+            ,"//result/doc/int[@name='val_i']"
+            
+            ,"//result/doc[count(*)=2]"
+            );
+  }
+
+  @Test
+  public void testFunctionsAndScore() throws Exception {
+
+    assertQ("fl=log(val_i),score",
+            req("q","*:*", "rows", "1", "fl","log(val_i),score")
+            ,"//result[@numFound='5']"
+            ,"//result/doc/float[@name='score']"
+            ,"//result/doc/double[@name='log(val_i)']"
+            
+            ,"//result/doc[count(*)=2]"
+            );
+    assertQ("fl=log(val_i)&fl=score",
+            req("q","*:*", "rows", "1", "fl","log(val_i)","fl","score")
+            ,"//result[@numFound='5']"
+            ,"//result/doc/float[@name='score']"
+            ,"//result/doc/double[@name='log(val_i)']"
+            
+            ,"//result/doc[count(*)=2]"
+            );
+
+    assertQ("fl=score,log(val_i),abs(val_i)",
+            req("q","*:*", "rows", "1", 
+                "fl","score,log(val_i),abs(val_i)")
+            ,"//result[@numFound='5']"
+            ,"//result/doc/float[@name='score']"
+            ,"//result/doc/double[@name='log(val_i)']"
+            ,"//result/doc/float[@name='abs(val_i)']"
+            
+            ,"//result/doc[count(*)=3]"
+            );
+    assertQ("fl=score&fl=log(val_i)&fl=abs(val_i)",
+            req("q","*:*", "rows", "1", 
+                "fl","score","fl","log(val_i)","fl","abs(val_i)")
+            ,"//result[@numFound='5']"
+            ,"//result/doc/float[@name='score']"
+            ,"//result/doc/double[@name='log(val_i)']"
+            ,"//result/doc/float[@name='abs(val_i)']"
+            
+            ,"//result/doc[count(*)=3]"
+            );
+    
+  }
+
+  @Test
+  public void testGlobs() throws Exception {
+    assertQ("fl=val_*",
+            req("q","*:*", "rows", "1", "fl","val_*")
+            ,"//result[@numFound='5']"
+            ,"//result/doc/int[@name='val_i']"
+            
+            ,"//result/doc[count(*)=1]"
+            );
+
+    assertQ("fl=val_*,subj*",
+            req("q","*:*", "rows", "1", "fl","val_*,subj*")
+            ,"//result[@numFound='5']"
+            ,"//result/doc/int[@name='val_i']"
+            ,"//result/doc/str[@name='subject']"
+            
+            ,"//result/doc[count(*)=2]"
+            );
+    assertQ("fl=val_*&fl=subj*",
+            req("q","*:*", "rows", "1", "fl","val_*","fl","subj*")
+            ,"//result[@numFound='5']"
+            ,"//result/doc/int[@name='val_i']"
+            ,"//result/doc/str[@name='subject']"
+            
+            ,"//result/doc[count(*)=2]"
+            );
+  }
+
+  @Test
+  public void testGlobsAndExplicit() throws Exception {
+    assertQ("fl=val_*,id",
+            req("q","*:*", "rows", "1", "fl","val_*,id")
+            ,"//result[@numFound='5']"
+            ,"//result/doc/int[@name='val_i']"
+            ,"//result/doc/str[@name='id']"
+            
+            ,"//result/doc[count(*)=2]"
+            );
+
+    assertQ("fl=val_*,subj*,id",
+            req("q","*:*", "rows", "1", "fl","val_*,subj*,id")
+            ,"//result[@numFound='5']"
+            ,"//result/doc/int[@name='val_i']"
+            ,"//result/doc/str[@name='subject']"
+            ,"//result/doc/str[@name='id']"
+            
+            ,"//result/doc[count(*)=3]"
+            );
+    assertQ("fl=val_*&fl=subj*&fl=id",
+            req("q","*:*", "rows", "1", "fl","val_*","fl","subj*","fl","id")
+            ,"//result[@numFound='5']"
+            ,"//result/doc/int[@name='val_i']"
+            ,"//result/doc/str[@name='subject']"
+            ,"//result/doc/str[@name='id']"
+            
+            ,"//result/doc[count(*)=3]"
+            );
+  }
+
+  @Test
+  public void testGlobsAndScore() throws Exception {
+    assertQ("fl=val_*,score",
+            req("q","*:*", "rows", "1", "fl","val_*,score", "indent", "true")
+            ,"//result[@numFound='5']"
+            ,"//result/doc/float[@name='score']"
+            ,"//result/doc/int[@name='val_i']"
+            
+            ,"//result/doc[count(*)=2]"
+            );
+
+    assertQ("fl=val_*,subj*,score",
+            req("q","*:*", "rows", "1", "fl","val_*,subj*,score")
+            ,"//result[@numFound='5']"
+            ,"//result/doc/float[@name='score']"
+            ,"//result/doc/int[@name='val_i']"
+            ,"//result/doc/str[@name='subject']"
+            
+            ,"//result/doc[count(*)=3]"
+            );
+    assertQ("fl=val_*&fl=subj*&fl=score",
+            req("q","*:*", "rows", "1", 
+                "fl","val_*","fl","subj*","fl","score")
+            ,"//result[@numFound='5']"
+            ,"//result/doc/float[@name='score']"
+            ,"//result/doc/int[@name='val_i']"
+            ,"//result/doc/str[@name='subject']"
+            
+            ,"//result/doc[count(*)=3]"
+            );
+
+    
+  }
+
+  @Test
+  public void testAugmenters() throws Exception {
+    assertQ("fl=[docid]",
+            req("q","*:*", "rows", "1", "fl","[docid]")
+            ,"//result[@numFound='5']"
+            ,"//result/doc/int[@name='[docid]']"
+            
+            ,"//result/doc[count(*)=1]"
+            );
+
+    assertQ("fl=[docid],[explain]",
+            req("q","*:*", "rows", "1", "fl","[docid],[explain]")
+            ,"//result[@numFound='5']"
+            ,"//result/doc/int[@name='[docid]']"
+            ,"//result/doc/str[@name='[explain]']"
+            
+            ,"//result/doc[count(*)=2]"
+            );
+    assertQ("fl=[docid]&fl=[explain]",
+            req("q","*:*", "rows", "1", "fl","[docid]","fl","[explain]")
+            ,"//result[@numFound='5']"
+            ,"//result/doc/int[@name='[docid]']"
+            ,"//result/doc/str[@name='[explain]']"
+            
+            ,"//result/doc[count(*)=2]"
+            );
+  }
+
+  @Test
+  public void testAugmentersAndExplicit() throws Exception {
+    assertQ("fl=[docid],id",
+            req("q","*:*", "rows", "1", 
+                "fl","[docid],id")
+            ,"//result[@numFound='5']"
+            ,"//result/doc/int[@name='[docid]']"
+            ,"//result/doc/str[@name='id']"
+            
+            ,"//result/doc[count(*)=2]"
+            );
+
+    assertQ("fl=[docid],[explain],id",
+            req("q","*:*", "rows", "1", 
+                "fl","[docid],[explain],id")
+            ,"//result[@numFound='5']"
+            ,"//result/doc/int[@name='[docid]']"
+            ,"//result/doc/str[@name='[explain]']"
+            ,"//result/doc/str[@name='id']"
+            
+            ,"//result/doc[count(*)=3]"
+            );
+    assertQ("fl=[docid]&fl=[explain]&fl=id",
+            req("q","*:*", "rows", "1", 
+                "fl","[docid]","fl","[explain]","fl","id")
+            ,"//result[@numFound='5']"
+            ,"//result/doc/int[@name='[docid]']"
+            ,"//result/doc/str[@name='[explain]']"
+            ,"//result/doc/str[@name='id']"
+            
+            ,"//result/doc[count(*)=3]"
+            );
+  }
+
+  @Test
+  public void testAugmentersAndScore() throws Exception {
+    assertQ("fl=[docid],score",
+            req("q","*:*", "rows", "1",
+                "fl","[docid],score")
+            ,"//result[@numFound='5']"
+            ,"//result/doc/float[@name='score']"
+            ,"//result/doc/int[@name='[docid]']"
+            
+            ,"//result/doc[count(*)=2]"
+            );
+
+    assertQ("fl=[docid],[explain],score",
+            req("q","*:*", "rows", "1",
+                "fl","[docid],[explain],score")
+            ,"//result[@numFound='5']"
+            ,"//result/doc/float[@name='score']"
+            ,"//result/doc/int[@name='[docid]']"
+            ,"//result/doc/str[@name='[explain]']"
+            
+            ,"//result/doc[count(*)=3]"
+            );
+    assertQ("fl=[docid]&fl=[explain]&fl=score",
+            req("q","*:*", "rows", "1", 
+                "fl","[docid]","fl","[explain]","fl","score")
+            ,"//result[@numFound='5']"
+            ,"//result/doc/float[@name='score']"
+            ,"//result/doc/int[@name='[docid]']"
+            ,"//result/doc/str[@name='[explain]']"
+            
+            ,"//result/doc[count(*)=3]"
+            );
+  }
+
+  @Test
+  public void testAugmentersGlobsExplicitAndScoreOhMy() throws Exception {
+
+    // NOTE: 'ssto' is the missing one
+    final List<String> fl = Arrays.asList
+      ("id","[docid]","[explain]","score","val_*","subj*");
+    
+    final int iters = atLeast(random, 10);
+    for (int i = 0; i< iters; i++) {
+      
+      Collections.shuffle(fl, random);
+
+      final String singleFl = StringUtils.join(fl.toArray(),',');
+      assertQ("fl=" + singleFl,
+              req("q","*:*", "rows", "1","fl",singleFl)
+              ,"//result[@numFound='5']"
+              ,"//result/doc/str[@name='id']"
+              ,"//result/doc/float[@name='score']"
+              ,"//result/doc/str[@name='subject']"
+              ,"//result/doc/int[@name='val_i']"
+              ,"//result/doc/int[@name='[docid]']"
+              ,"//result/doc/str[@name='[explain]']"
+              
+              ,"//result/doc[count(*)=6]"
+              );
+
+      final List<String> params = new ArrayList<String>((fl.size()*2) + 4);
+      final StringBuilder info = new StringBuilder();
+      params.addAll(Arrays.asList("q","*:*", "rows", "1"));
+      for (String item : fl) {
+        params.add("fl");
+        params.add(item);
+        info.append("&fl=").append(item);
+      }
+      
+      assertQ(info.toString(),
+              req((String[])params.toArray(new String[0]))
+              ,"//result[@numFound='5']"
+              ,"//result/doc/str[@name='id']"
+              ,"//result/doc/float[@name='score']"
+              ,"//result/doc/str[@name='subject']"
+              ,"//result/doc/int[@name='val_i']"
+              ,"//result/doc/int[@name='[docid]']"
+              ,"//result/doc/str[@name='[explain]']"
+              
+              ,"//result/doc[count(*)=6]"
+              );
+
+    }
+  }
+}

Modified: lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/util/DOMUtilTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/util/DOMUtilTestBase.java?rev=1305339&r1=1305338&r2=1305339&view=diff
==============================================================================
--- lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/util/DOMUtilTestBase.java (original)
+++ lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/util/DOMUtilTestBase.java Mon Mar 26 12:58:58 2012
@@ -1,56 +1,56 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.solr.util;
-
-
-import java.io.StringReader;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathFactory;
-
-import org.apache.lucene.util.LuceneTestCase;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.xml.sax.InputSource;
-
-public abstract class DOMUtilTestBase extends LuceneTestCase {
-  
-  private DocumentBuilder builder;
-  private static final XPathFactory xpathFactory = XPathFactory.newInstance();
-  
-  @Override
-  public void setUp() throws Exception {
-    super.setUp();
-    builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
-  }
-
-  public Node getNode( String xml, String path ) throws Exception {
-    return getNode( getDocument(xml), path );
-  }
-  
-  public Node getNode( Document doc, String path ) throws Exception {
-    XPath xpath = xpathFactory.newXPath();
-    return (Node)xpath.evaluate(path, doc, XPathConstants.NODE);
-  }
-  
-  public Document getDocument( String xml ) throws Exception {
-    return builder.parse(new InputSource(new StringReader(xml)));
-  }
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.util;
+
+
+import java.io.StringReader;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.lucene.util.LuceneTestCase;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.xml.sax.InputSource;
+
+public abstract class DOMUtilTestBase extends LuceneTestCase {
+  
+  private DocumentBuilder builder;
+  private static final XPathFactory xpathFactory = XPathFactory.newInstance();
+  
+  @Override
+  public void setUp() throws Exception {
+    super.setUp();
+    builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+  }
+
+  public Node getNode( String xml, String path ) throws Exception {
+    return getNode( getDocument(xml), path );
+  }
+  
+  public Node getNode( Document doc, String path ) throws Exception {
+    XPath xpath = xpathFactory.newXPath();
+    return (Node)xpath.evaluate(path, doc, XPathConstants.NODE);
+  }
+  
+  public Document getDocument( String xml ) throws Exception {
+    return builder.parse(new InputSource(new StringReader(xml)));
+  }
+}