Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/handler/component/TermVectorComponentTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/handler/component/TermVectorComponentTest.java?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/handler/component/TermVectorComponentTest.java
(original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/handler/component/TermVectorComponentTest.java
Thu Jul 22 19:34:35 2010
@@ -1,7 +1,6 @@
package org.apache.solr.handler.component;
import org.apache.solr.SolrTestCaseJ4;
-import org.apache.solr.util.AbstractSolrTestCase;
import org.apache.solr.core.SolrCore;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.CommonParams;
@@ -19,6 +18,7 @@ import static org.junit.Assert.*;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.List;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -46,18 +46,77 @@ public class TermVectorComponentTest ext
public static void beforeClass() throws Exception {
initCore("solrconfig.xml","schema.xml");
- assertNull(h.validateUpdate(adoc("id", "0", "test_posofftv", "This is a title and another
title")));
- assertNull(h.validateUpdate(adoc("id", "1", "test_posofftv",
- "The quick reb fox jumped over the lazy brown dogs.")));
- assertNull(h.validateUpdate(adoc("id", "2", "test_posofftv", "This is a document")));
- assertNull(h.validateUpdate(adoc("id", "3", "test_posofftv", "another document")));
+ assertNull(h.validateUpdate(adoc("id", "0",
+ "test_posofftv", "This is a title and another title",
+ "test_basictv", "This is a title and another title",
+ "test_notv", "This is a title and another title",
+ "test_postv", "This is a title and another title",
+ "test_offtv", "This is a title and another title"
+ )));
+ assertNull(h.validateUpdate(adoc("id", "1",
+ "test_posofftv", "The quick reb fox jumped over the lazy brown dogs.",
+ "test_basictv", "The quick reb fox jumped over the lazy brown dogs.",
+ "test_notv", "The quick reb fox jumped over the lazy brown dogs.",
+ "test_postv", "The quick reb fox jumped over the lazy brown dogs.",
+ "test_offtv", "The quick reb fox jumped over the lazy brown dogs."
+ )));
+ assertNull(h.validateUpdate(adoc("id", "2",
+ "test_posofftv", "This is a document",
+ "test_basictv", "This is a document",
+ "test_notv", "This is a document",
+ "test_postv", "This is a document",
+ "test_offtv", "This is a document"
+ )));
+ assertNull(h.validateUpdate(adoc("id", "3",
+ "test_posofftv", "another document",
+ "test_basictv", "another document",
+ "test_notv", "another document",
+ "test_postv", "another document",
+ "test_offtv", "another document"
+ )));
//bunch of docs that are variants on blue
- assertNull(h.validateUpdate(adoc("id", "4", "test_posofftv", "blue")));
- assertNull(h.validateUpdate(adoc("id", "5", "test_posofftv", "blud")));
- assertNull(h.validateUpdate(adoc("id", "6", "test_posofftv", "boue")));
- assertNull(h.validateUpdate(adoc("id", "7", "test_posofftv", "glue")));
- assertNull(h.validateUpdate(adoc("id", "8", "test_posofftv", "blee")));
- assertNull(h.validateUpdate(adoc("id", "9", "test_posofftv", "blah")));
+ assertNull(h.validateUpdate(adoc("id", "4",
+ "test_posofftv", "blue",
+ "test_basictv", "blue",
+ "test_notv", "blue",
+ "test_postv", "blue",
+ "test_offtv", "blue"
+ )));
+ assertNull(h.validateUpdate(adoc("id", "5",
+ "test_posofftv", "blud",
+ "test_basictv", "blud",
+ "test_notv", "blud",
+ "test_postv", "blud",
+ "test_offtv", "blud"
+ )));
+ assertNull(h.validateUpdate(adoc("id", "6",
+ "test_posofftv", "boue",
+ "test_basictv", "boue",
+ "test_notv", "boue",
+ "test_postv", "boue",
+ "test_offtv", "boue"
+ )));
+ assertNull(h.validateUpdate(adoc("id", "7",
+ "test_posofftv", "glue",
+ "test_basictv", "glue",
+ "test_notv", "glue",
+ "test_postv", "glue",
+ "test_offtv", "glue"
+ )));
+ assertNull(h.validateUpdate(adoc("id", "8",
+ "test_posofftv", "blee",
+ "test_basictv", "blee",
+ "test_notv", "blee",
+ "test_postv", "blee",
+ "test_offtv", "blee"
+ )));
+ assertNull(h.validateUpdate(adoc("id", "9",
+ "test_posofftv", "blah",
+ "test_basictv", "blah",
+ "test_notv", "blah",
+ "test_postv", "blah",
+ "test_offtv", "blah"
+ )));
assertNull(h.validateUpdate(commit()));
}
@@ -80,10 +139,10 @@ public class TermVectorComponentTest ext
NamedList values = rsp.getValues();
NamedList termVectors = (NamedList) values.get(TermVectorComponent.TERM_VECTORS);
assertTrue("termVectors is null and it shouldn't be", termVectors != null);
- // System.out.println("TVs:" + termVectors);
+ if (VERBOSE) System.out.println("TVs:" + termVectors);
NamedList doc = (NamedList) termVectors.getVal(0);
assertTrue("doc is null and it shouldn't be", doc != null);
- assertTrue(doc.size() + " does not equal: " + 2, doc.size() == 2);
+ assertEquals(doc.size(), 5);
NamedList field = (NamedList) doc.get("test_posofftv");
assertTrue("field is null and it shouldn't be", field != null);
assertTrue(field.size() + " does not equal: " + 2, field.size() == 2);
@@ -127,7 +186,7 @@ public class TermVectorComponentTest ext
// System.out.println("TVs: " + termVectors);
NamedList doc = (NamedList) termVectors.getVal(0);
assertTrue("doc is null and it shouldn't be", doc != null);
- assertTrue(doc.size() + " does not equal: " + 2, doc.size() == 2);
+ assertEquals(doc.size(), 5);
NamedList offtv = (NamedList) doc.get("test_posofftv");
assertTrue("offtv is null and it shouldn't be", offtv != null);
assertTrue("offtv Size: " + offtv.size() + " is not: " + 2, offtv.size() == 2);
@@ -144,22 +203,37 @@ public class TermVectorComponentTest ext
Double tfIdf = (Double) another.get("tf-idf");
assertTrue("tfIdf is null and it shouldn't be", tfIdf != null);
assertTrue(tfIdf + " does not equal: " + 0.5, tfIdf == 0.5);
-
-
}
+ /*
+<field name="test_basictv" type="text" termVectors="true"/>
+ <field name="test_notv" type="text" termVectors="false"/>
+ <field name="test_postv" type="text" termVectors="true" termPositions="true"/>
+ <field name="test_offtv" type="text" termVectors="true" termOffsets="true"/>
+ <field name="test_posofftv" type="text" termVectors="true"
+ termPositions="true" termOffsets="true"/>
+ */
@Test
- public void testNoFields() throws Exception {
+ public void testPerField() throws Exception {
SolrCore core = h.getCore();
SearchComponent tvComp = core.getSearchComponent("tvComponent");
assertTrue("tvComp is null and it shouldn't be", tvComp != null);
ModifiableSolrParams params = new ModifiableSolrParams();
params.add(CommonParams.Q, "id:0");
params.add(CommonParams.QT, "tvrh");
+ params.add(TermVectorParams.FIELDS, "test_basictv,test_notv,test_postv,test_offtv,test_posofftv");
params.add(TermVectorParams.TF, "true");
- //Pass in a field that doesn't exist on the doc, thus, no vectors should be returned
- params.add(TermVectorParams.FIELDS, "foo");
+ params.add(TermVectorParams.DF, "true");
+ params.add(TermVectorParams.OFFSETS, "true");
+ params.add(TermVectorParams.POSITIONS, "true");
+ params.add(TermVectorParams.TF_IDF, "true");
params.add(TermVectorComponent.COMPONENT_NAME, "true");
+ //per field
+ params.add("f.test_posofftv." + TermVectorParams.POSITIONS, "false");
+ params.add("f.test_offtv." + TermVectorParams.OFFSETS, "false");
+ params.add("f.test_basictv." + TermVectorParams.DF, "false");
+ params.add("f.test_basictv." + TermVectorParams.TF, "false");
+ params.add("f.test_basictv." + TermVectorParams.TF_IDF, "false");
SolrRequestHandler handler = core.getRequestHandler("tvrh");
SolrQueryResponse rsp;
rsp = new SolrQueryResponse();
@@ -168,12 +242,104 @@ public class TermVectorComponentTest ext
NamedList values = rsp.getValues();
NamedList termVectors = (NamedList) values.get(TermVectorComponent.TERM_VECTORS);
assertTrue("termVectors is null and it shouldn't be", termVectors != null);
- NamedList doc = (NamedList) termVectors.getVal(0);
+ if (VERBOSE) System.out.println("TVs: " + termVectors);
+ NamedList doc = (NamedList) termVectors.get("doc-0");
assertTrue("doc is null and it shouldn't be", doc != null);
- assertTrue(doc.size() + " does not equal: " + 1, doc.size() == 1);
+ assertEquals(doc.size(), 5);
+ NamedList vec;
+ NamedList another;
+ NamedList offsets;
+ NamedList pos;
+ Integer df;
+ Double val;
+ vec = (NamedList) doc.get("test_posofftv");
+ assertNotNull(vec);
+ assertEquals(vec.size(), 2);
+ another = (NamedList) vec.get("anoth");
+ offsets = (NamedList) another.get("offsets");
+ assertNotNull(offsets);
+ assertTrue(offsets.size() > 0);
+ pos = (NamedList) another.get("positions");
+ //positions should be null, since we turned them off
+ assertNull(pos);
+ df = (Integer) another.get("df");
+ assertNotNull(df);
+ assertTrue(df == 2);
+ val = (Double) another.get("tf-idf");
+ assertTrue("tfIdf is null and it shouldn't be", val != null);
+ assertTrue(val + " does not equal: " + 0.5, val == 0.5);
+ //Try out the other fields, too
+ vec = (NamedList) doc.get("test_offtv");
+ assertNotNull(vec);
+ assertEquals(vec.size(), 2);
+ another = (NamedList) vec.get("anoth");
+ offsets = (NamedList) another.get("offsets");
+ assertNull(offsets);
+ pos = (NamedList) another.get("positions");
+ //positions should be null, since we turned them off
+ assertNull(vec.toString(), pos);
+ df = (Integer) another.get("df");
+ assertNotNull(df);
+ assertTrue(df == 2);
+ val = (Double) another.get("tf-idf");
+ assertTrue("tfIdf is null and it shouldn't be", val != null);
+ assertTrue(val + " does not equal: " + 0.5, val == 0.5);
+ vec = (NamedList) doc.get("test_basictv");
+ assertNotNull(vec);
+ assertEquals(vec.size(), 2);
+ another = (NamedList) vec.get("anoth");
+ offsets = (NamedList) another.get("offsets");
+ assertNull(offsets);
+ pos = (NamedList) another.get("positions");
+ assertNull(pos);
+ df = (Integer) another.get("df");
+ assertNull(df);
+ val = (Double) another.get("tf-idf");
+ assertNull(val);
+ val = (Double) another.get("tf");
+ assertNull(val);
+ //Now validate we have error messages
+ NamedList warnings = (NamedList) termVectors.get("warnings");
+ assertNotNull(warnings);
+ List<String> theList;
+ theList = (List<String>) warnings.get("noTermVectors");
+ assertNotNull(theList);
+ assertEquals(theList.size(), 1);
+ theList = (List<String>) warnings.get("noPositions");
+ assertNotNull(theList);
+ assertEquals(theList.size(), 2);
+ theList = (List<String>) warnings.get("noOffsets");
+ assertNotNull(theList);
+ assertEquals(theList.size(), 2);
}
@Test
+ public void testNoFields() throws Exception {
+ ignoreException("undefined field: foo");
+ SolrCore core = h.getCore();
+ SearchComponent tvComp = core.getSearchComponent("tvComponent");
+ assertTrue("tvComp is null and it shouldn't be", tvComp != null);
+ ModifiableSolrParams params = new ModifiableSolrParams();
+ params.add(CommonParams.Q, "id:0");
+ params.add(CommonParams.QT, "tvrh");
+ params.add(TermVectorParams.TF, "true");
+ //Pass in a field that doesn't exist on the doc, thus, no vectors should be returned
+ params.add(TermVectorParams.FIELDS, "foo");
+ params.add(TermVectorComponent.COMPONENT_NAME, "true");
+ SolrRequestHandler handler = core.getRequestHandler("tvrh");
+ SolrQueryResponse rsp;
+ rsp = new SolrQueryResponse();
+ rsp.add("responseHeader", new SimpleOrderedMap());
+ handler.handleRequest(new LocalSolrQueryRequest(core, params), rsp);
+ Exception exception = rsp.getException();
+ assertNotNull(exception);
+ resetExceptionIgnores();
+ }
+
+
+
+
+ @Test
public void testDistributed() throws Exception {
SolrCore core = h.getCore();
TermVectorComponent tvComp = (TermVectorComponent) core.getSearchComponent("tvComponent");
Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/request/TestFaceting.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/request/TestFaceting.java?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/request/TestFaceting.java
(original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/request/TestFaceting.java
Thu Jul 22 19:34:35 2010
@@ -18,6 +18,7 @@
package org.apache.solr.request;
import org.apache.lucene.index.Term;
+import org.apache.lucene.util.BytesRef;
import org.apache.solr.SolrTestCaseJ4;
import org.junit.After;
import org.junit.BeforeClass;
@@ -68,7 +69,7 @@ public class TestFaceting extends SolrTe
req = lrf.makeRequest("q","*:*");
TermIndex ti = new TermIndex(proto.field());
- NumberedTermEnum te = ti.getEnumerator(req.getSearcher().getReader());
+ NumberedTermsEnum te = ti.getEnumerator(req.getSearcher().getReader());
// iterate through first
while(te.term() != null) te.next();
@@ -82,11 +83,11 @@ public class TestFaceting extends SolrTe
for (int i=0; i<size*2+10; i++) {
int rnum = r.nextInt(size+2);
String s = t(rnum);
- boolean b = te.skipTo(proto.createTerm(s));
- assertEquals(b, rnum < size);
+ BytesRef br = te.skipTo(new BytesRef(s));
+ assertEquals(br != null, rnum < size);
if (rnum < size) {
assertEquals(rnum, te.pos);
- assertEquals(s, te.term().text());
+ assertEquals(s, te.term().utf8ToString());
} else {
assertEquals(null, te.term());
assertEquals(size, te.getTermNumber());
@@ -94,10 +95,10 @@ public class TestFaceting extends SolrTe
}
// test seeking before term
- assertEquals(size>0, te.skipTo(proto.createTerm("000")));
+ assertEquals(size>0, te.skipTo(new BytesRef("000")) != null);
assertEquals(0, te.getTermNumber());
if (size>0) {
- assertEquals(t(0), te.term().text());
+ assertEquals(t(0), te.term().utf8ToString());
} else {
assertEquals(null, te.term());
}
@@ -107,10 +108,10 @@ public class TestFaceting extends SolrTe
for (int i=0; i<size*2+10; i++) {
int rnum = r.nextInt(size);
String s = t(rnum);
- boolean b = te.skipTo(rnum);
- assertEquals(true, b);
+ BytesRef br = te.skipTo(rnum);
+ assertNotNull(br);
assertEquals(rnum, te.pos);
- assertEquals(s, te.term().text());
+ assertEquals(s, te.term().utf8ToString());
}
}
}
@@ -204,7 +205,6 @@ public class TestFaceting extends SolrTe
sb.append(t(i));
sb.append(' ');
}
- String many_ws = sb.toString();
int i1=1000000;
Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/schema/PolyFieldTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/schema/PolyFieldTest.java?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/schema/PolyFieldTest.java
(original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/schema/PolyFieldTest.java
Thu Jul 22 19:34:35 2010
@@ -22,6 +22,8 @@ import org.apache.lucene.search.BooleanQ
import org.apache.lucene.search.Query;
import org.apache.lucene.spatial.tier.CartesianPolyFilterBuilder;
import org.apache.lucene.spatial.tier.Shape;
+import org.apache.lucene.spatial.tier.projections.CartesianTierPlotter;
+import org.apache.lucene.spatial.tier.projections.SinusoidalProjector;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.core.SolrCore;
import org.apache.solr.common.SolrException;
@@ -185,39 +187,4 @@ public class PolyFieldTest extends SolrT
clearIndex();
}
- @Test
- public void testCartesian() throws Exception {
- for (int i = 40; i < 50; i++) {
- for (int j = -85; j < -79; j++) {
- assertU(adoc("id", "" + i, "home_tier",
- i + "," + j));
- }
- }
- assertU(commit());
- CartesianPolyFilterBuilder cpfb = new CartesianPolyFilterBuilder("", 4, 15);
- //Get the box based on this point and our distance
- final Shape shape = cpfb.getBoxShape(45, -80, 10);//There's a bit of a bug in here that
requires a small tier filter here.
- final List<Double> boxIds = shape.getArea();
- //do a box id search
- StringBuilder qry = new StringBuilder();
- boolean first = true;
- for (Double boxId : boxIds) {
- if (first == true){
- first = false;
- } else {
- qry.append(" OR ");
- }
- qry.append("home_tier:");
- if (boxId < 0) {
- qry.append('\\').append(boxId);
- } else {
- qry.append(boxId);
- }
- }
-
- assertQ(req("fl", "*,score", "indent", "true", "q", qry.toString()),
- "//*[@numFound='1']");
- clearIndex();
- }
-
}
\ No newline at end of file
Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/search/TestDocSet.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/search/TestDocSet.java?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/search/TestDocSet.java
(original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/search/TestDocSet.java
Thu Jul 22 19:34:35 2010
@@ -108,7 +108,7 @@ public class TestDocSet extends TestCase
}
public void checkEqual(OpenBitSet bs, DocSet set) {
- for (int i=0; i<bs.capacity(); i++) {
+ for (int i=0; i<set.size(); i++) {
assertEquals(bs.get(i), set.exists(i));
}
assertEquals(bs.cardinality(), set.size());
Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/search/TestRangeQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/search/TestRangeQuery.java?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/search/TestRangeQuery.java
(original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/search/TestRangeQuery.java
Thu Jul 22 19:34:35 2010
@@ -16,30 +16,33 @@
*/
package org.apache.solr.search;
-import org.apache.solr.util.AbstractSolrTestCase;
+import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.response.SolrQueryResponse;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
import java.util.*;
import junit.framework.TestCase;
-public class TestRangeQuery extends AbstractSolrTestCase {
-
- public String getSchemaFile() { return "schema11.xml"; }
- public String getSolrConfigFile() { return "solrconfig.xml"; }
- public String getCoreName() { return "basic"; }
+public class TestRangeQuery extends SolrTestCaseJ4 {
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema11.xml");
+ }
+ @Before
public void setUp() throws Exception {
// if you override setUp or tearDown, you better call
// the super classes version
super.setUp();
- }
- public void tearDown() throws Exception {
- // if you override setUp or tearDown, you better call
- // the super classes version
- super.tearDown();
+ clearIndex();
+ assertU(commit());
}
Random r = new Random(1);
@@ -69,7 +72,7 @@ public class TestRangeQuery extends Abst
}
}
-
+ @Test
public void testRangeQueries() throws Exception {
// ensure that we aren't losing precision on any fields in addition to testing other
non-numeric fields
// that aren't tested in testRandomRangeQueries()
@@ -197,6 +200,7 @@ public class TestRangeQuery extends Abst
}
+ @Test
public void testRandomRangeQueries() throws Exception {
String handler="";
final String[] fields = {"foo_s","foo_i","foo_l","foo_f","foo_d" // SortableIntField,
etc
Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/search/function/TestFunctionQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/search/function/TestFunctionQuery.java?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/search/function/TestFunctionQuery.java
(original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/search/function/TestFunctionQuery.java
Thu Jul 22 19:34:35 2010
@@ -17,53 +17,39 @@
package org.apache.solr.search.function;
-import org.apache.lucene.analysis.ngram.EdgeNGramTokenFilter;
-import org.apache.lucene.queryParser.ParseException;
-import org.apache.lucene.search.Query;
-import org.apache.solr.search.ValueSourceParser;
-import org.apache.solr.search.FunctionQParser;
-import org.apache.solr.search.function.DocValues;
-import org.apache.solr.search.function.QueryValueSource;
-import org.apache.solr.search.function.SimpleFloatFunction;
-import org.apache.solr.search.function.ValueSource;
-import org.apache.solr.util.AbstractSolrTestCase;
-import org.apache.solr.common.util.NamedList;
-import org.apache.solr.core.SolrCore;
+import org.apache.lucene.search.DefaultSimilarity;
+import org.apache.lucene.search.FieldCache;
+import org.apache.lucene.search.Similarity;
+import org.apache.solr.SolrTestCaseJ4;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import java.io.FileOutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import java.util.Random;
-import java.util.Arrays;
-import java.io.File;
-import java.io.Writer;
-import java.io.OutputStreamWriter;
-import java.io.FileOutputStream;
+
+import static org.junit.Assert.assertTrue;
/**
* Tests some basic functionality of Solr while demonstrating good
* Best Practices for using AbstractSolrTestCase
*/
-public class TestFunctionQuery extends AbstractSolrTestCase {
-
- public String getSchemaFile() { return "schema11.xml"; }
- public String getSolrConfigFile() { return "solrconfig-functionquery.xml"; }
- public String getCoreName() { return "basic"; }
-
- public void setUp() throws Exception {
- // if you override setUp or tearDown, you better call
- // the super classes version
- super.setUp();
- }
- public void tearDown() throws Exception {
- // if you override setUp or tearDown, you better call
- // the super classes version
- super.tearDown();
+public class TestFunctionQuery extends SolrTestCaseJ4 {
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig-functionquery.xml","schema11.xml");
}
+
String base = "external_foo_extf";
+ static long start = System.currentTimeMillis();
void makeExternalFile(String field, String contents, String charset) {
String dir = h.getCore().getDataDir();
- String filename = dir + "/external_" + field + "." + System.currentTimeMillis();
+ String filename = dir + "/external_" + field + "." + (start++);
try {
Writer out = new OutputStreamWriter(new FileOutputStream(filename), charset);
out.write(contents);
@@ -196,14 +182,18 @@ public class TestFunctionQuery extends A
singleTest(field,"sum(query($v1,5),query($v1,7))",
Arrays.asList("v1","\0:[* TO *]"), 88,12
);
+
+ purgeFieldCache(FieldCache.DEFAULT); // avoid FC insanity
}
+ @Test
public void testFunctions() {
doTest("foo_pf"); // a plain float field
doTest("foo_f"); // a sortable float field
doTest("foo_tf"); // a trie float field
}
+ @Test
public void testExternalField() {
String field = "foo_extf";
@@ -224,7 +214,8 @@ public class TestFunctionQuery extends A
makeExternalFile(field, "0=1","UTF-8");
assertU(adoc("id", "10000")); // will get same reader if no index change
- assertU(commit());
+ assertU(commit());
+ singleTest(field, "sqrt(\0)");
assertTrue(orig != FileFloatSource.onlyForTesting);
@@ -276,19 +267,39 @@ public class TestFunctionQuery extends A
singleTest(field, "\0", answers);
// System.out.println("Done test "+i);
}
+
+ purgeFieldCache(FieldCache.DEFAULT); // avoid FC insanity
}
+ @Test
public void testGeneral() throws Exception {
+ clearIndex();
+
assertU(adoc("id","1", "a_tdt","2009-08-31T12:10:10.123Z", "b_tdt","2009-08-31T12:10:10.124Z"));
- assertU(adoc("id","2"));
+ assertU(adoc("id","2", "a_t","how now brown cow"));
assertU(commit()); // create more than one segment
- assertU(adoc("id","3"));
+ assertU(adoc("id","3", "a_t","brown cow"));
assertU(adoc("id","4"));
assertU(commit()); // create more than one segment
assertU(adoc("id","5"));
- assertU(adoc("id","6"));
+ assertU(adoc("id","6", "a_t","cow cow cow cow cow"));
assertU(commit());
+ // test relevancy functions
+ assertQ(req("fl","*,score","q", "{!func}numdocs()", "fq","id:6"), "//float[@name='score']='6.0'");
+ assertQ(req("fl","*,score","q", "{!func}maxdoc()", "fq","id:6"), "//float[@name='score']='6.0'");
+ assertQ(req("fl","*,score","q", "{!func}docfreq(a_t,cow)", "fq","id:6"), "//float[@name='score']='3.0'");
+ assertQ(req("fl","*,score","q", "{!func}docfreq('a_t','cow')", "fq","id:6"), "//float[@name='score']='3.0'");
+ assertQ(req("fl","*,score","q", "{!func}docfreq($field,$value)", "fq","id:6", "field","a_t",
"value","cow"), "//float[@name='score']='3.0'");
+ assertQ(req("fl","*,score","q", "{!func}termfreq(a_t,cow)", "fq","id:6"), "//float[@name='score']='5.0'");
+ Similarity similarity = new DefaultSimilarity();
+ assertQ(req("fl","*,score","q", "{!func}idf(a_t,cow)", "fq","id:6"),
+ "//float[@name='score']='" + similarity.idf(3,6) + "'");
+ assertQ(req("fl","*,score","q", "{!func}tf(a_t,cow)", "fq","id:6"),
+ "//float[@name='score']='" + similarity.tf(5) + "'");
+ assertQ(req("fl","*,score","q", "{!func}norm(a_t)", "fq","id:2"),
+ "//float[@name='score']='" + similarity.lengthNorm("a_t",4) + "'"); // sqrt(4)==2
and is exactly representable when quantized to a byte
+
// test that ord and rord are working on a global index basis, not just
// at the segment level (since Lucene 2.9 has switched to per-segment searching)
assertQ(req("fl","*,score","q", "{!func}ord(id)", "fq","id:6"), "//float[@name='score']='6.0'");
@@ -327,11 +338,12 @@ public class TestFunctionQuery extends A
assertQ(req("fl","*,score","q", q, "qq","text:batman", "fq",fq), "//float[@name='score']<'1.0'");
assertQ(req("fl","*,score","q", q, "qq","text:superman", "fq",fq), "//float[@name='score']>'1.0'");
- doTestDegreeRads();
- doTestFuncs();
+
+ purgeFieldCache(FieldCache.DEFAULT); // avoid FC insanity
}
- public void doTestDegreeRads() throws Exception {
+ @Test
+ public void testDegreeRads() throws Exception {
assertU(adoc("id", "1", "x_td", "0", "y_td", "0"));
assertU(adoc("id", "2", "x_td", "90", "y_td", String.valueOf(Math.PI / 2)));
assertU(adoc("id", "3", "x_td", "45", "y_td", String.valueOf(Math.PI / 4)));
@@ -347,6 +359,7 @@ public class TestFunctionQuery extends A
assertQ(req("fl", "*,score", "q", "{!func}deg(y_td)", "fq", "id:3"), "//float[@name='score']='45.0'");
}
+ @Test
public void testStrDistance() throws Exception {
assertU(adoc("id", "1", "x_s", "foil"));
assertU(commit());
@@ -363,7 +376,8 @@ public class TestFunctionQuery extends A
"//float[@name='score']='" + sval + "'");
}
- public void doTestFuncs() throws Exception {
+ @Test
+ public void testFuncs() throws Exception {
assertU(adoc("id", "1", "foo_d", "9"));
assertU(commit());
Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/search/function/distance/DistanceFunctionTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/search/function/distance/DistanceFunctionTest.java?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/search/function/distance/DistanceFunctionTest.java
(original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/search/function/distance/DistanceFunctionTest.java
Thu Jul 22 19:34:35 2010
@@ -16,6 +16,7 @@ package org.apache.solr.search.function.
* limitations under the License.
*/
+import org.apache.lucene.spatial.DistanceUtils;
import org.apache.lucene.spatial.geohash.GeoHashUtils;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrException;
@@ -55,17 +56,17 @@ public class DistanceFunctionTest extend
//Geo Hash Haversine
//Can verify here: http://www.movable-type.co.uk/scripts/latlong.html, but they use a
slightly different radius for the earth, so just be close
- assertQ(req("fl", "*,score", "q", "{!func}ghhsin(" + Constants.EARTH_RADIUS_KM + ", gh_s,
\"" + GeoHashUtils.encode(32, -79) +
- "\",)", "fq", "id:1"), "//float[@name='score']='122.309006'");
+ assertQ(req("fl", "*,score", "q", "{!func}ghhsin(" + DistanceUtils.EARTH_MEAN_RADIUS_KM
+ ", gh_s, \"" + GeoHashUtils.encode(32, -79) +
+ "\",)", "fq", "id:1"), "//float[@name='score']='122.171875'");
- assertQ(req("fl", "id,point_hash,score", "q", "{!func}recip(ghhsin(" + Constants.EARTH_RADIUS_KM
+ ", point_hash, \"" + GeoHashUtils.encode(32, -79) + "\"), 1, 1, 0)"),
+ assertQ(req("fl", "id,point_hash,score", "q", "{!func}recip(ghhsin(" + DistanceUtils.EARTH_MEAN_RADIUS_KM
+ ", point_hash, \"" + GeoHashUtils.encode(32, -79) + "\"), 1, 1, 0)"),
"//*[@numFound='7']",
"//result/doc[1]/float[@name='id'][.='6.0']",
"//result/doc[2]/float[@name='id'][.='7.0']"//all the rest don't matter
);
- assertQ(req("fl", "*,score", "q", "{!func}ghhsin(" + Constants.EARTH_RADIUS_KM + ", gh_s,
geohash(32, -79))", "fq", "id:1"), "//float[@name='score']='122.309006'");
+ assertQ(req("fl", "*,score", "q", "{!func}ghhsin(" + DistanceUtils.EARTH_MEAN_RADIUS_KM
+ ", gh_s, geohash(32, -79))", "fq", "id:1"), "//float[@name='score']='122.171875'");
}
@Test
Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/servlet/SolrRequestParserTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/servlet/SolrRequestParserTest.java?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/servlet/SolrRequestParserTest.java
(original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/servlet/SolrRequestParserTest.java
Thu Jul 22 19:34:35 2010
@@ -22,6 +22,7 @@ import static org.easymock.EasyMock.expe
import static org.easymock.EasyMock.replay;
import java.net.URL;
+import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -111,7 +112,11 @@ public class SolrRequestParserTest exten
String url = "http://www.apache.org/dist/lucene/solr/";
String txt = null;
try {
- txt = IOUtils.toString( new URL(url).openStream() );
+ URLConnection connection = new URL(url).openConnection();
+ connection.setConnectTimeout(5000);
+ connection.setReadTimeout(5000);
+ connection.connect();
+ txt = IOUtils.toString( connection.getInputStream());
}
catch( Exception ex ) {
// TODO - should it fail/skip?
Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java
(original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/update/DirectUpdateHandlerTest.java
Thu Jul 22 19:34:35 2010
@@ -17,22 +17,14 @@
package org.apache.solr.update;
-import java.io.IOException;
-import java.util.ArrayList;
import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
import java.util.Map;
-import java.util.Set;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.Field.Index;
import org.apache.lucene.document.Field.Store;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.SegmentReader;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.index.TermEnum;
+import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.MapSolrParams;
@@ -40,20 +32,31 @@ import org.apache.solr.core.SolrCore;
import org.apache.solr.request.LocalSolrQueryRequest;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.search.SolrIndexReader;
-import org.apache.solr.search.SolrIndexSearcher;
-import org.apache.solr.util.AbstractSolrTestCase;
-import org.apache.solr.util.RefCounted;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
/**
*
*
*/
-public class DirectUpdateHandlerTest extends AbstractSolrTestCase {
+public class DirectUpdateHandlerTest extends SolrTestCaseJ4 {
- public String getSchemaFile() { return "schema12.xml"; }
- public String getSolrConfigFile() { return "solrconfig.xml"; }
-
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema12.xml");
+ }
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ clearIndex();
+ assertU(commit());
+ }
+
+ @Test
public void testRequireUniqueKey() throws Exception
{
SolrCore core = h.getCore();
@@ -94,6 +97,7 @@ public class DirectUpdateHandlerTest ext
catch( SolrException ex ) { } // expected
}
+ @Test
public void testUncommit() throws Exception {
addSimpleDoc("A");
@@ -107,6 +111,7 @@ public class DirectUpdateHandlerTest ext
);
}
+ @Test
public void testAddCommit() throws Exception {
addSimpleDoc("A");
@@ -128,6 +133,7 @@ public class DirectUpdateHandlerTest ext
);
}
+ @Test
public void testDeleteCommit() throws Exception {
addSimpleDoc("A");
addSimpleDoc("B");
@@ -170,7 +176,12 @@ public class DirectUpdateHandlerTest ext
);
}
+ @Test
public void testAddRollback() throws Exception {
+ // re-init the core
+ deleteCore();
+ initCore("solrconfig.xml", "schema12.xml");
+
addSimpleDoc("A");
// commit "A"
@@ -220,7 +231,12 @@ public class DirectUpdateHandlerTest ext
);
}
+ @Test
public void testDeleteRollback() throws Exception {
+ // re-init the core
+ deleteCore();
+ initCore("solrconfig.xml", "schema12.xml");
+
addSimpleDoc("A");
addSimpleDoc("B");
@@ -287,6 +303,7 @@ public class DirectUpdateHandlerTest ext
);
}
+ @Test
public void testExpungeDeletes() throws Exception {
assertU(adoc("id","1"));
assertU(adoc("id","2"));
Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/update/DocumentBuilderTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/update/DocumentBuilderTest.java?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/update/DocumentBuilderTest.java
(original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/update/DocumentBuilderTest.java
Thu Jul 22 19:34:35 2010
@@ -18,22 +18,28 @@
package org.apache.solr.update;
import org.apache.lucene.document.Document;
+import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.core.SolrCore;
-import org.apache.solr.util.AbstractSolrTestCase;
import org.apache.solr.schema.FieldType;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
/**
*
*
*/
-public class DocumentBuilderTest extends AbstractSolrTestCase {
+public class DocumentBuilderTest extends SolrTestCaseJ4 {
- @Override public String getSchemaFile() { return "schema.xml"; }
- @Override public String getSolrConfigFile() { return "solrconfig.xml"; }
-
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema.xml");
+ }
+ @Test
public void testBuildDocument() throws Exception
{
SolrCore core = h.getCore();
@@ -50,6 +56,7 @@ public class DocumentBuilderTest extends
}
}
+ @Test
public void testNullField()
{
SolrCore core = h.getCore();
@@ -61,6 +68,7 @@ public class DocumentBuilderTest extends
assertNull( out.get( "name" ) );
}
+ @Test
public void testMultiField() throws Exception {
SolrCore core = h.getCore();
Modified: lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java
(original)
+++ lucene/dev/branches/realtime_search/solr/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java
Thu Jul 22 19:34:35 2010
@@ -21,6 +21,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
+import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.params.MultiMapSolrParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.params.UpdateParams;
@@ -31,32 +32,35 @@ import org.apache.solr.core.SolrCore;
import org.apache.solr.handler.XmlUpdateRequestHandler;
import org.apache.solr.request.SolrQueryRequestBase;
import org.apache.solr.response.SolrQueryResponse;
-import org.apache.solr.util.AbstractSolrTestCase;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
/**
*
*/
-public class SignatureUpdateProcessorFactoryTest extends AbstractSolrTestCase {
+public class SignatureUpdateProcessorFactoryTest extends SolrTestCaseJ4 {
/** modified by tests as needed */
private String processor = "dedupe";
- @Override
- public String getSchemaFile() {
- return "schema12.xml";
- }
-
- @Override
- public String getSolrConfigFile() {
- return "solrconfig.xml";
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig.xml", "schema12.xml");
}
@Override
+ @Before
public void setUp() throws Exception {
super.setUp();
+ clearIndex();
+ assertU(commit());
processor = "dedupe"; // set the default that most tests expect
}
+ @Test
public void testDupeDetection() throws Exception {
SolrCore core = h.getCore();
UpdateRequestProcessorChain chained = core.getUpdateProcessingChain(
@@ -103,6 +107,7 @@ public class SignatureUpdateProcessorFac
factory.setEnabled(false);
}
+ @Test
public void testMultiThreaded() throws Exception {
UpdateRequestProcessorChain chained = h.getCore().getUpdateProcessingChain(
"dedupe");
@@ -182,6 +187,7 @@ public class SignatureUpdateProcessorFac
/**
* a non-indexed signatureField is fine as long as overwriteDupes==false
*/
+ @Test
public void testNonIndexedSignatureField() throws Exception {
SolrCore core = h.getCore();
@@ -197,6 +203,7 @@ public class SignatureUpdateProcessorFac
2l, core.getSearcher().get().getReader().numDocs());
}
+ @Test
public void testFailNonIndexedSigWithOverwriteDupes() throws Exception {
SolrCore core = h.getCore();
SignatureUpdateProcessorFactory f = new SignatureUpdateProcessorFactory();
Modified: lucene/dev/branches/realtime_search/solr/src/test/test-files/solr/conf/schema.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/test-files/solr/conf/schema.xml?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/test-files/solr/conf/schema.xml (original)
+++ lucene/dev/branches/realtime_search/solr/src/test/test-files/solr/conf/schema.xml Thu
Jul 22 19:34:35 2010
@@ -373,11 +373,14 @@
<!-- Try out some point types -->
<fieldType name="xy" class="solr.PointType" dimension="2" subFieldType="double"/>
+ <fieldType name="x" class="solr.PointType" dimension="1" subFieldType="double"/>
<fieldType name="tenD" class="solr.PointType" dimension="10" subFieldType="double"/>
<!-- Use the sub field suffix -->
<fieldType name="xyd" class="solr.PointType" dimension="2" subFieldSuffix="*_d"/>
+ <fieldtype name="geohash" class="solr.GeoHashField"/>
- <fieldType name="tier" class="solr.SpatialTileField" start="4" end="15" subFieldType="double"/>
+
+ <fieldType name="latLon" class="solr.LatLonType" subFieldType="double"/>
</types>
@@ -406,11 +409,14 @@
<!-- Test points -->
<!-- Test points -->
<field name="home" type="xy" indexed="true" stored="true" multiValued="false"/>
+ <field name="x" type="x" indexed="true" stored="true" multiValued="false"/>
<field name="homed" type="xyd" indexed="true" stored="true" multiValued="false"/>
<field name="home_ns" type="xy" indexed="true" stored="false" multiValued="false"/>
<field name="work" type="xy" indexed="true" stored="true" multiValued="false"/>
- <field name="home_tier" type="tier" indexed="true" stored="true" multiValued="false"/>
+ <field name="home_ll" type="latLon" indexed="true" stored="true" multiValued="false"/>
+ <field name="home_gh" type="geohash" indexed="true" stored="true" multiValued="false"/>
+
<field name="point10" type="tenD" indexed="true" stored="true" multiValued="false"/>
Modified: lucene/dev/branches/realtime_search/solr/src/test/test-files/solr/conf/solrconfig-delpolicy1.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/test-files/solr/conf/solrconfig-delpolicy1.xml?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/test-files/solr/conf/solrconfig-delpolicy1.xml
(original)
+++ lucene/dev/branches/realtime_search/solr/src/test/test-files/solr/conf/solrconfig-delpolicy1.xml
Thu Jul 22 19:34:35 2010
@@ -97,7 +97,7 @@
<str name="keepOptimizedOnly">true</str>
<str name="maxCommitsToKeep">3</str>
- <str name="maxCommitAge">5SECONDS</str>
+ <str name="maxCommitAge">100MILLISECONDS</str>
</deletionPolicy>
Modified: lucene/dev/branches/realtime_search/solr/src/test/test-files/solr/conf/solrconfig-functionquery.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/test/test-files/solr/conf/solrconfig-functionquery.xml?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/test/test-files/solr/conf/solrconfig-functionquery.xml
(original)
+++ lucene/dev/branches/realtime_search/solr/src/test/test-files/solr/conf/solrconfig-functionquery.xml
Thu Jul 22 19:34:35 2010
@@ -114,13 +114,13 @@
class="solr.search.LRUCache"
size="512"
initialSize="512"
- autowarmCount="256"/>
+ autowarmCount="0"/>
<queryResultCache
class="solr.search.LRUCache"
size="512"
initialSize="512"
- autowarmCount="1024"/>
+ autowarmCount="0"/>
<documentCache
class="solr.search.LRUCache"
Propchange: lucene/dev/branches/realtime_search/solr/src/webapp/src/org/apache/solr/client/solrj/embedded/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jul 22 19:34:35 2010
@@ -1,2 +1,3 @@
-/lucene/dev/branches/branch_3x/solr/src/webapp/src/org/apache/solr/client/solrj/embedded:949730
+/lucene/dev/branches/branch_3x/solr/src/webapp/src/org/apache/solr/client/solrj/embedded:949730,961612
+/lucene/dev/trunk/solr/src/webapp/src/org/apache/solr/client/solrj/embedded:953476-966816
/lucene/solr/trunk/src/webapp/src/org/apache/solr/client/solrj/embedded:922950-923910,923912-925091
Modified: lucene/dev/branches/realtime_search/solr/src/webapp/web/admin/index.jsp
URL: http://svn.apache.org/viewvc/lucene/dev/branches/realtime_search/solr/src/webapp/web/admin/index.jsp?rev=966819&r1=966818&r2=966819&view=diff
==============================================================================
--- lucene/dev/branches/realtime_search/solr/src/webapp/web/admin/index.jsp (original)
+++ lucene/dev/branches/realtime_search/solr/src/webapp/web/admin/index.jsp Thu Jul 22 19:34:35
2010
@@ -58,11 +58,16 @@
<%-- List the cores (that arent this one) so we can switch --%>
<% org.apache.solr.core.CoreContainer cores = (org.apache.solr.core.CoreContainer)request.getAttribute("org.apache.solr.CoreContainer");
if (cores!=null) {
- Collection<SolrCore> names = cores.getCores();
+ Collection<String> names = cores.getCoreNames();
if (names.size() > 1) {%><tr><td><strong>Cores:</strong><br></td><td><%
- for (SolrCore name : names) {
- if(name.equals(core.getName())) continue;
- %>[<a href="../../<%=name.getName()%>/admin/"><%=name%></a>]<%
+ String url = request.getContextPath();
+ for (String name : names) {
+ String lname = name.length()==0 ? cores.getDefaultCoreName() : name; // use the real
core name rather than the default
+ if(name.equals(core.getName())) {
+ %>[<%=lname%>]<%
+ } else {
+ %>[<a href="<%=url%>/<%=lname%>/admin/"><%=lname%></a>]<%
+ }
}%></td></tr><%
}}%>
|