You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by si...@apache.org on 2012/05/29 09:18:19 UTC
svn commit: r1343567 [2/2] - in /lucene/dev/branches/LUCENE-2878/solr: ./
cloud-dev/ contrib/
contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/
core/ core/src/java/org/apache/solr/analysis/
core/src/java/org/apache/solr/cloud/ core...
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test-files/solr/conf/solrconfig.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test-files/solr/conf/solrconfig.xml?rev=1343567&r1=1343566&r2=1343567&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test-files/solr/conf/solrconfig.xml (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test-files/solr/conf/solrconfig.xml Tue May 29 07:18:15 2012
@@ -507,4 +507,35 @@
<processor class="solr.RunUpdateProcessorFactory" />
</updateRequestProcessorChain>
+ <updateRequestProcessorChain name="distrib-dup-test-chain-explicit">
+ <!-- explicit test using processors before and after distrib -->
+ <processor class="solr.RegexReplaceProcessorFactory">
+ <str name="fieldName">regex_dup_A_s</str>
+ <str name="pattern">x</str>
+ <str name="replacement">x_x</str>
+ </processor>
+ <processor class="solr.DistributedUpdateProcessorFactory" />
+ <processor class="solr.RegexReplaceProcessorFactory">
+ <str name="fieldName">regex_dup_B_s</str>
+ <str name="pattern">x</str>
+ <str name="replacement">x_x</str>
+ </processor>
+ <processor class="solr.RunUpdateProcessorFactory" />
+ </updateRequestProcessorChain>
+
+ <updateRequestProcessorChain name="distrib-dup-test-chain-implicit">
+ <!-- implicit test w/o distrib declared-->
+ <processor class="solr.RegexReplaceProcessorFactory">
+ <str name="fieldName">regex_dup_A_s</str>
+ <str name="pattern">x</str>
+ <str name="replacement">x_x</str>
+ </processor>
+ <processor class="solr.RegexReplaceProcessorFactory">
+ <str name="fieldName">regex_dup_B_s</str>
+ <str name="pattern">x</str>
+ <str name="replacement">x_x</str>
+ </processor>
+ <processor class="solr.RunUpdateProcessorFactory" />
+ </updateRequestProcessorChain>
+
</config>
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java?rev=1343567&r1=1343566&r2=1343567&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZkTest.java Tue May 29 07:18:15 2012
@@ -48,12 +48,17 @@ import org.apache.solr.client.solrj.requ
import org.apache.solr.client.solrj.request.ContentStreamUpdateRequest;
import org.apache.solr.client.solrj.request.CoreAdminRequest.Create;
import org.apache.solr.client.solrj.request.QueryRequest;
+import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.client.solrj.response.QueryResponse;
+import org.apache.solr.client.solrj.response.UpdateResponse;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.cloud.Slice;
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.params.CommonParams;
+import org.apache.solr.common.params.UpdateParams;
+import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.update.SolrCmdDistributor.Request;
@@ -123,9 +128,10 @@ public class BasicDistributedZkTest exte
@Override
public void doTest() throws Exception {
- setLoggingLevel(null);
+ // setLoggingLevel(null);
del("*:*");
+
indexr(id,1, i1, 100, tlong, 100,t1,"now is the time for all good men"
,"foo_f", 1.414f, "foo_b", "true", "foo_d", 1.414d);
indexr(id,2, i1, 50 , tlong, 50,t1,"to come to the aid of their country."
@@ -289,6 +295,9 @@ public class BasicDistributedZkTest exte
testSearchByCollectionName();
testANewCollectionInOneInstanceWithManualShardAssignement();
testNumberOfCommitsWithCommitAfterAdd();
+
+ testUpdateProcessorsRunOnlyOnce("distrib-dup-test-chain-explicit");
+ testUpdateProcessorsRunOnlyOnce("distrib-dup-test-chain-implicit");
// Thread.sleep(10000000000L);
if (DEBUG) {
@@ -296,6 +305,54 @@ public class BasicDistributedZkTest exte
}
}
+ /**
+ * Expects a RegexReplaceProcessorFactories in the chain which will
+ * "double up" the values in two (stored) string fields.
+ * <p>
+ * If the values are "double-doubled" or "not-doubled" then we know
+ * the processor was not run the appropriate number of times
+ * </p>
+ */
+ private void testUpdateProcessorsRunOnlyOnce(final String chain) throws Exception {
+
+ final String fieldA = "regex_dup_A_s";
+ final String fieldB = "regex_dup_B_s";
+ final String val = "x";
+ final String expected = "x_x";
+ final ModifiableSolrParams updateParams = new ModifiableSolrParams();
+ updateParams.add(UpdateParams.UPDATE_CHAIN, chain);
+
+ final int numLoops = atLeast(50);
+
+ for (int i = 1; i < numLoops; i++) {
+ // add doc to random client
+ SolrServer updateClient = clients.get(random().nextInt(clients.size()));
+ SolrInputDocument doc = new SolrInputDocument();
+ addFields(doc, id, i, fieldA, val, fieldB, val);
+ UpdateResponse ures = add(updateClient, updateParams, doc);
+ assertEquals(chain + ": update failed", 0, ures.getStatus());
+ ures = updateClient.commit();
+ assertEquals(chain + ": commit failed", 0, ures.getStatus());
+ }
+
+ // query for each doc, and check both fields to ensure the value is correct
+ for (int i = 1; i < numLoops; i++) {
+ final String query = id + ":" + i;
+ QueryResponse qres = queryServer(new SolrQuery(query));
+ assertEquals(chain + ": query failed: " + query,
+ 0, qres.getStatus());
+ assertEquals(chain + ": didn't find correct # docs with query: " + query,
+ 1, qres.getResults().getNumFound());
+ SolrDocument doc = qres.getResults().get(0);
+
+ for (String field : new String[] {fieldA, fieldB}) {
+ assertEquals(chain + ": doc#" + i+ " has wrong value for " + field,
+ expected, doc.getFirstValue(field));
+ }
+ }
+
+ }
+
// cloud level test mainly needed just to make sure that versions and errors are propagated correctly
private void doOptimisticLockingAndUpdating() throws Exception {
SolrInputDocument sd = sdoc("id", 1000, "_version_", -1);
@@ -334,7 +391,6 @@ public class BasicDistributedZkTest exte
}
}
-
private void testNumberOfCommitsWithCommitAfterAdd()
throws MalformedURLException, SolrServerException, IOException {
long startCommits = getNumCommits((HttpSolrServer) clients.get(0));
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudTest.java?rev=1343567&r1=1343566&r2=1343567&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudTest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudTest.java Tue May 29 07:18:15 2012
@@ -59,7 +59,6 @@ import org.junit.Ignore;
* what we test now - the default update chain
*
*/
-@Ignore
public class FullSolrCloudTest extends AbstractDistributedZkTestCase {
@BeforeClass
public static void beforeFullSolrCloudTest() throws Exception {
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java?rev=1343567&r1=1343566&r2=1343567&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java Tue May 29 07:18:15 2012
@@ -118,6 +118,7 @@ public class DistributedSpellCheckCompon
index(id, "22", "lowerfilt", "The quote red fox jumped over the lazy brown dogs.");
index(id, "23", "lowerfilt", "The quote red fox jumped over the lazy brown dogs.");
index(id, "24", "lowerfilt", "The quote red fox jumped over the lazy brown dogs.");
+ index(id, "25", "lowerfilt", "rod fix");
commit();
handle.clear();
@@ -138,5 +139,7 @@ public class DistributedSpellCheckCompon
query("q", "lowerfilt:(+quock +reb)", "fl", "id,lowerfilt", "spellcheck", "true", "qt", requestHandlerName, "shards.qt", requestHandlerName, SpellingParams.SPELLCHECK_EXTENDED_RESULTS, "true", SpellingParams.SPELLCHECK_COUNT, "10", SpellingParams.SPELLCHECK_COLLATE, "true", SpellingParams.SPELLCHECK_MAX_COLLATION_TRIES, "10", SpellingParams.SPELLCHECK_MAX_COLLATIONS, "10", SpellingParams.SPELLCHECK_COLLATE_EXTENDED_RESULTS, "false");
query("q", "lowerfilt:(+quock +reb)", "fl", "id,lowerfilt", "spellcheck", "true", "qt", requestHandlerName, "shards.qt", requestHandlerName, SpellingParams.SPELLCHECK_EXTENDED_RESULTS, "true", SpellingParams.SPELLCHECK_COUNT, "10", SpellingParams.SPELLCHECK_COLLATE, "true", SpellingParams.SPELLCHECK_MAX_COLLATION_TRIES, "0", SpellingParams.SPELLCHECK_MAX_COLLATIONS, "1", SpellingParams.SPELLCHECK_COLLATE_EXTENDED_RESULTS, "false");
+ query("q", "lowerfilt:(\"quote red fox\")", "fl", "id,lowerfilt", "spellcheck", "true", "qt", "spellCheckCompRH", "shards.qt", "spellCheckCompRH", SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS, "true", SpellCheckComponent.SPELLCHECK_COUNT, "10", SpellCheckComponent.SPELLCHECK_COLLATE, "true", SpellCheckComponent.SPELLCHECK_MAX_COLLATION_TRIES, "10", SpellCheckComponent.SPELLCHECK_MAX_COLLATIONS, "1", SpellCheckComponent.SPELLCHECK_COLLATE_EXTENDED_RESULTS, "true", SpellCheckComponent.SPELLCHECK_ALTERNATIVE_TERM_COUNT, "5", SpellCheckComponent.SPELLCHECK_MAX_RESULTS_FOR_SUGGEST, "10");
+ query("q", "lowerfilt:(\"rod fix\")", "fl", "id,lowerfilt", "spellcheck", "true", "qt", "spellCheckCompRH", "shards.qt", "spellCheckCompRH", SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS, "true", SpellCheckComponent.SPELLCHECK_COUNT, "10", SpellCheckComponent.SPELLCHECK_COLLATE, "true", SpellCheckComponent.SPELLCHECK_MAX_COLLATION_TRIES, "10", SpellCheckComponent.SPELLCHECK_MAX_COLLATIONS, "1", SpellCheckComponent.SPELLCHECK_COLLATE_EXTENDED_RESULTS, "true", SpellCheckComponent.SPELLCHECK_ALTERNATIVE_TERM_COUNT, "5", SpellCheckComponent.SPELLCHECK_MAX_RESULTS_FOR_SUGGEST, "10");
}
}
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java?rev=1343567&r1=1343566&r2=1343567&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/handler/component/SpellCheckComponentTest.java Tue May 29 07:18:15 2012
@@ -124,10 +124,16 @@ public class SpellCheckComponentTest ext
@Test
public void testCorrectSpelling() throws Exception {
// Make sure correct spellings are signaled in the response
- assertJQ(req("json.nl","map", "qt",rh, SpellCheckComponent.COMPONENT_NAME, "true", "q","lowerfilt:lazy lowerfilt:brown", SpellingParams.SPELLCHECK_EXTENDED_RESULTS, "true")
+ assertJQ(req("json.nl","map", "qt",rh, SpellCheckComponent.COMPONENT_NAME, "true",
+ "q","lowerfilt:lazy lowerfilt:brown", SpellingParams.SPELLCHECK_EXTENDED_RESULTS, "true")
,"/spellcheck/suggestions=={'correctlySpelled':true}"
);
- assertJQ(req("json.nl","map", "qt",rh, SpellCheckComponent.COMPONENT_NAME, "true", "q","lakkle", SpellingParams.SPELLCHECK_EXTENDED_RESULTS, "true")
+ assertJQ(req("json.nl","map", "qt",rh, SpellCheckComponent.COMPONENT_NAME, "true", "spellcheck.dictionary", "direct_lowerfilt",
+ "q","lowerfilt:lazy lowerfilt:brown", SpellingParams.SPELLCHECK_EXTENDED_RESULTS, "true")
+ ,"/spellcheck/suggestions=={'correctlySpelled':true}"
+ );
+ assertJQ(req("json.nl","map", "qt",rh, SpellCheckComponent.COMPONENT_NAME, "true", "spellcheck.dictionary", "direct_lowerfilt",
+ "q","lakkle", SpellingParams.SPELLCHECK_EXTENDED_RESULTS, "true")
,"/spellcheck/suggestions/correctlySpelled==false"
);
}
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestDocSet.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestDocSet.java?rev=1343567&r1=1343566&r2=1343567&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestDocSet.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestDocSet.java Tue May 29 07:18:15 2012
@@ -21,6 +21,7 @@ import java.io.IOException;
import java.util.Arrays;
import java.util.Random;
+import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.FieldInfos;
import org.apache.lucene.index.DocValues;
import org.apache.lucene.index.StoredFieldVisitor;
@@ -365,7 +366,7 @@ public class TestDocSet extends LuceneTe
@Override
public FieldInfos getFieldInfos() {
- return new FieldInfos();
+ return new FieldInfos(new FieldInfo[0]);
}
@Override
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java?rev=1343567&r1=1343566&r2=1343567&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestExtendedDismaxParser.java Tue May 29 07:18:15 2012
@@ -597,5 +597,29 @@ public class TestExtendedDismaxParser ex
"debugQuery", "true",
"defType", "edismax"),
"//doc[1]/str[@name='id'][.='s1']");
+
+ assertQ("ps/ps2/ps3 with default slop overrides not working",
+ req("q", "zzzz xxxx cccc vvvv",
+ "qf", "phrase_sw",
+ "pf", "phrase_sw~1^10 phrase_sw~2^20 phrase_sw^30",
+ "pf2", "phrase_sw~2^22 phrase_sw^33",
+ "pf3", "phrase_sw~2^222 phrase_sw^333",
+ "ps", "3",
+ "defType", "edismax",
+ "debugQuery", "true"),
+ "//str[@name='parsedquery'][contains(.,'phrase_sw:\"zzzz xxxx cccc vvvv\"~1^10.0')]",
+ "//str[@name='parsedquery'][contains(.,'phrase_sw:\"zzzz xxxx cccc vvvv\"~2^20.0')]",
+ "//str[@name='parsedquery'][contains(.,'phrase_sw:\"zzzz xxxx cccc vvvv\"~3^30.0')]",
+ "//str[@name='parsedquery'][contains(.,'phrase_sw:\"zzzz xxxx\"~2^22.0')]",
+ "//str[@name='parsedquery'][contains(.,'phrase_sw:\"xxxx cccc\"~2^22.0')]",
+ "//str[@name='parsedquery'][contains(.,'phrase_sw:\"cccc vvvv\"~2^22.0')]",
+ "//str[@name='parsedquery'][contains(.,'phrase_sw:\"zzzz xxxx\"~3^33.0')]",
+ "//str[@name='parsedquery'][contains(.,'phrase_sw:\"xxxx cccc\"~3^33.0')]",
+ "//str[@name='parsedquery'][contains(.,'phrase_sw:\"cccc vvvv\"~3^33.0')]",
+ "//str[@name='parsedquery'][contains(.,'phrase_sw:\"zzzz xxxx cccc\"~2^222.0')]",
+ "//str[@name='parsedquery'][contains(.,'phrase_sw:\"xxxx cccc vvvv\"~2^222.0')]",
+ "//str[@name='parsedquery'][contains(.,'phrase_sw:\"zzzz xxxx cccc\"~3^333.0')]",
+ "//str[@name='parsedquery'][contains(.,'phrase_sw:\"xxxx cccc vvvv\"~3^333.0')]"
+ );
}
}
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestRealTimeGet.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestRealTimeGet.java?rev=1343567&r1=1343566&r2=1343567&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestRealTimeGet.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestRealTimeGet.java Tue May 29 07:18:15 2012
@@ -48,11 +48,13 @@ import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import static org.apache.solr.core.SolrCore.verbose;
-import static org.apache.solr.update.processor.DistributedUpdateProcessor.SEEN_LEADER;
+import static org.apache.solr.update.processor.DistributingUpdateProcessorFactory.DISTRIB_UPDATE_PARAM;
+import static org.apache.solr.update.processor.DistributedUpdateProcessor.DistribPhase;
public class TestRealTimeGet extends SolrTestCaseJ4 {
- private static String SEEN_LEADER_VAL="true"; // value that means we've seen the leader and have version info (i.e. we are a non-leader replica)
+ // means we've seen the leader and have version info (i.e. we are a non-leader replica)
+ private static String FROM_LEADER = DistribPhase.FROMLEADER.toString();
@BeforeClass
public static void beforeClass() throws Exception {
@@ -149,7 +151,7 @@ public class TestRealTimeGet extends Sol
// simulate an update from the leader
version += 10;
- updateJ(jsonAdd(sdoc("id","1", "_version_",Long.toString(version))), params(SEEN_LEADER,SEEN_LEADER_VAL));
+ updateJ(jsonAdd(sdoc("id","1", "_version_",Long.toString(version))), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
// test version is there from rtg
assertJQ(req("qt","/get","id","1")
@@ -157,7 +159,7 @@ public class TestRealTimeGet extends Sol
);
// simulate reordering: test that a version less than that does not take affect
- updateJ(jsonAdd(sdoc("id","1", "_version_",Long.toString(version - 1))), params(SEEN_LEADER,SEEN_LEADER_VAL));
+ updateJ(jsonAdd(sdoc("id","1", "_version_",Long.toString(version - 1))), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
// test that version hasn't changed
assertJQ(req("qt","/get","id","1")
@@ -166,7 +168,7 @@ public class TestRealTimeGet extends Sol
// simulate reordering: test that a delete w/ version less than that does not take affect
// TODO: also allow passing version on delete instead of on URL?
- updateJ(jsonDelId("1"), params(SEEN_LEADER,SEEN_LEADER_VAL, "_version_",Long.toString(version - 1)));
+ updateJ(jsonDelId("1"), params(DISTRIB_UPDATE_PARAM,FROM_LEADER, "_version_",Long.toString(version - 1)));
// test that version hasn't changed
assertJQ(req("qt","/get","id","1")
@@ -177,7 +179,7 @@ public class TestRealTimeGet extends Sol
assertU(commit());
// simulate reordering: test that a version less than that does not take affect
- updateJ(jsonAdd(sdoc("id","1", "_version_",Long.toString(version - 1))), params(SEEN_LEADER,SEEN_LEADER_VAL));
+ updateJ(jsonAdd(sdoc("id","1", "_version_",Long.toString(version - 1))), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
// test that version hasn't changed
assertJQ(req("qt","/get","id","1")
@@ -185,7 +187,7 @@ public class TestRealTimeGet extends Sol
);
// simulate reordering: test that a delete w/ version less than that does not take affect
- updateJ(jsonDelId("1"), params(SEEN_LEADER,SEEN_LEADER_VAL, "_version_",Long.toString(version - 1)));
+ updateJ(jsonDelId("1"), params(DISTRIB_UPDATE_PARAM,FROM_LEADER, "_version_",Long.toString(version - 1)));
// test that version hasn't changed
assertJQ(req("qt","/get","id","1")
@@ -194,10 +196,10 @@ public class TestRealTimeGet extends Sol
// now simulate a normal delete from the leader
version += 5;
- updateJ(jsonDelId("1"), params(SEEN_LEADER,SEEN_LEADER_VAL, "_version_",Long.toString(version)));
+ updateJ(jsonDelId("1"), params(DISTRIB_UPDATE_PARAM,FROM_LEADER, "_version_",Long.toString(version)));
// make sure a reordered add doesn't take affect.
- updateJ(jsonAdd(sdoc("id","1", "_version_",Long.toString(version - 1))), params(SEEN_LEADER,SEEN_LEADER_VAL));
+ updateJ(jsonAdd(sdoc("id","1", "_version_",Long.toString(version - 1))), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
// test that it's still deleted
assertJQ(req("qt","/get","id","1")
@@ -208,7 +210,7 @@ public class TestRealTimeGet extends Sol
assertU(commit());
// make sure a reordered add doesn't take affect.
- updateJ(jsonAdd(sdoc("id","1", "_version_",Long.toString(version - 1))), params(SEEN_LEADER,SEEN_LEADER_VAL));
+ updateJ(jsonAdd(sdoc("id","1", "_version_",Long.toString(version - 1))), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
// test that it's still deleted
assertJQ(req("qt","/get","id","1")
@@ -1071,7 +1073,7 @@ public class TestRealTimeGet extends Sol
if (oper < commitPercent + deletePercent) {
verbose("deleting id",id,"val=",nextVal,"version",version);
- Long returnedVersion = deleteAndGetVersion(Integer.toString(id), params("_version_",Long.toString(-version), SEEN_LEADER,SEEN_LEADER_VAL));
+ Long returnedVersion = deleteAndGetVersion(Integer.toString(id), params("_version_",Long.toString(-version), DISTRIB_UPDATE_PARAM,FROM_LEADER));
// TODO: returning versions for these types of updates is redundant
// but if we do return, they had better be equal
@@ -1093,7 +1095,7 @@ public class TestRealTimeGet extends Sol
} else {
verbose("adding id", id, "val=", nextVal,"version",version);
- Long returnedVersion = addAndGetVersion(sdoc("id", Integer.toString(id), field, Long.toString(nextVal), "_version_",Long.toString(version)), params(SEEN_LEADER,SEEN_LEADER_VAL));
+ Long returnedVersion = addAndGetVersion(sdoc("id", Integer.toString(id), field, Long.toString(nextVal), "_version_",Long.toString(version)), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
if (returnedVersion != null) {
assertEquals(version, returnedVersion.longValue());
}
@@ -1341,7 +1343,7 @@ public class TestRealTimeGet extends Sol
if (oper < commitPercent + deletePercent) {
verbose("deleting id",id,"val=",nextVal,"version",version);
- Long returnedVersion = deleteAndGetVersion(Integer.toString(id), params("_version_",Long.toString(-version), SEEN_LEADER,SEEN_LEADER_VAL));
+ Long returnedVersion = deleteAndGetVersion(Integer.toString(id), params("_version_",Long.toString(-version), DISTRIB_UPDATE_PARAM,FROM_LEADER));
// TODO: returning versions for these types of updates is redundant
// but if we do return, they had better be equal
@@ -1363,7 +1365,7 @@ public class TestRealTimeGet extends Sol
} else {
verbose("adding id", id, "val=", nextVal,"version",version);
- Long returnedVersion = addAndGetVersion(sdoc("id", Integer.toString(id), field, Long.toString(nextVal), "_version_",Long.toString(version)), params(SEEN_LEADER,SEEN_LEADER_VAL));
+ Long returnedVersion = addAndGetVersion(sdoc("id", Integer.toString(id), field, Long.toString(nextVal), "_version_",Long.toString(version)), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
if (returnedVersion != null) {
assertEquals(version, returnedVersion.longValue());
}
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestRecovery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestRecovery.java?rev=1343567&r1=1343566&r2=1343567&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestRecovery.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/search/TestRecovery.java Tue May 29 07:18:15 2012
@@ -1,4 +1,4 @@
-/**
+/*
* 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.
@@ -39,10 +39,14 @@ import java.util.concurrent.Future;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
-import static org.apache.solr.update.processor.DistributedUpdateProcessor.SEEN_LEADER;
+import static org.apache.solr.update.processor.DistributingUpdateProcessorFactory.DISTRIB_UPDATE_PARAM;
+import static org.apache.solr.update.processor.DistributedUpdateProcessor.DistribPhase;
public class TestRecovery extends SolrTestCaseJ4 {
- private static String SEEN_LEADER_VAL="true"; // value that means we've seen the leader and have version info (i.e. we are a non-leader replica)
+
+ // means that we've seen the leader and have version info (i.e. we are a non-leader replica)
+ private static String FROM_LEADER = DistribPhase.FROMLEADER.toString();
+
private static int timeout=60; // acquire timeout in seconds. change this to a huge number when debugging to prevent threads from advancing.
// TODO: fix this test to not require FSDirectory
@@ -214,12 +218,12 @@ public class TestRecovery extends SolrTe
assertEquals(UpdateLog.State.BUFFERING, ulog.getState());
// simulate updates from a leader
- updateJ(jsonAdd(sdoc("id","B1", "_version_","1010")), params(SEEN_LEADER,SEEN_LEADER_VAL));
- updateJ(jsonAdd(sdoc("id","B11", "_version_","1015")), params(SEEN_LEADER,SEEN_LEADER_VAL));
- updateJ(jsonDelQ("id:B1 id:B11 id:B2 id:B3"), params(SEEN_LEADER,SEEN_LEADER_VAL, "_version_","-1017"));
- updateJ(jsonAdd(sdoc("id","B2", "_version_","1020")), params(SEEN_LEADER,SEEN_LEADER_VAL));
- updateJ(jsonAdd(sdoc("id","B3", "_version_","1030")), params(SEEN_LEADER,SEEN_LEADER_VAL));
- deleteAndGetVersion("B1", params(SEEN_LEADER,SEEN_LEADER_VAL, "_version_","-2010"));
+ updateJ(jsonAdd(sdoc("id","B1", "_version_","1010")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
+ updateJ(jsonAdd(sdoc("id","B11", "_version_","1015")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
+ updateJ(jsonDelQ("id:B1 id:B11 id:B2 id:B3"), params(DISTRIB_UPDATE_PARAM,FROM_LEADER, "_version_","-1017"));
+ updateJ(jsonAdd(sdoc("id","B2", "_version_","1020")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
+ updateJ(jsonAdd(sdoc("id","B3", "_version_","1030")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
+ deleteAndGetVersion("B1", params(DISTRIB_UPDATE_PARAM,FROM_LEADER, "_version_","-2010"));
assertJQ(req("qt","/get", "getVersions","6")
,"=={'versions':[-2010,1030,1020,-1017,1015,1010]}"
@@ -272,18 +276,18 @@ public class TestRecovery extends SolrTe
assertEquals(1030L, ver.longValue());
// add a reordered doc that shouldn't overwrite one in the index
- updateJ(jsonAdd(sdoc("id","B3", "_version_","3")), params(SEEN_LEADER,SEEN_LEADER_VAL));
+ updateJ(jsonAdd(sdoc("id","B3", "_version_","3")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
// reorder two buffered updates
- updateJ(jsonAdd(sdoc("id","B4", "_version_","1040")), params(SEEN_LEADER,SEEN_LEADER_VAL));
- deleteAndGetVersion("B4", params(SEEN_LEADER,SEEN_LEADER_VAL, "_version_","-940")); // this update should not take affect
- updateJ(jsonAdd(sdoc("id","B6", "_version_","1060")), params(SEEN_LEADER,SEEN_LEADER_VAL));
- updateJ(jsonAdd(sdoc("id","B5", "_version_","1050")), params(SEEN_LEADER,SEEN_LEADER_VAL));
- updateJ(jsonAdd(sdoc("id","B8", "_version_","1080")), params(SEEN_LEADER,SEEN_LEADER_VAL));
+ updateJ(jsonAdd(sdoc("id","B4", "_version_","1040")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
+ deleteAndGetVersion("B4", params(DISTRIB_UPDATE_PARAM,FROM_LEADER, "_version_","-940")); // this update should not take affect
+ updateJ(jsonAdd(sdoc("id","B6", "_version_","1060")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
+ updateJ(jsonAdd(sdoc("id","B5", "_version_","1050")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
+ updateJ(jsonAdd(sdoc("id","B8", "_version_","1080")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
// test that delete by query is at least buffered along with everything else so it will delete the
// currently buffered id:8 (even if it doesn't currently support versioning)
- updateJ("{\"delete\": { \"query\":\"id:B2 OR id:B8\" }}", params(SEEN_LEADER,SEEN_LEADER_VAL, "_version_","-3000"));
+ updateJ("{\"delete\": { \"query\":\"id:B2 OR id:B8\" }}", params(DISTRIB_UPDATE_PARAM,FROM_LEADER, "_version_","-3000"));
assertJQ(req("qt","/get", "getVersions","13")
,"=={'versions':[-3000,1080,1050,1060,-940,1040,3,-2010,1030,1020,-1017,1015,1010]}" // the "3" appears because versions aren't checked while buffering
@@ -298,12 +302,12 @@ public class TestRecovery extends SolrTe
logReplay.release(1);
// now add another update
- updateJ(jsonAdd(sdoc("id","B7", "_version_","1070")), params(SEEN_LEADER,SEEN_LEADER_VAL));
+ updateJ(jsonAdd(sdoc("id","B7", "_version_","1070")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
// a reordered update that should be dropped
- deleteAndGetVersion("B5", params(SEEN_LEADER,SEEN_LEADER_VAL, "_version_","-950"));
+ deleteAndGetVersion("B5", params(DISTRIB_UPDATE_PARAM,FROM_LEADER, "_version_","-950"));
- deleteAndGetVersion("B6", params(SEEN_LEADER,SEEN_LEADER_VAL, "_version_","-2060"));
+ deleteAndGetVersion("B6", params(DISTRIB_UPDATE_PARAM,FROM_LEADER, "_version_","-2060"));
logReplay.release(1000);
UpdateLog.RecoveryInfo recInfo = rinfoFuture.get();
@@ -376,14 +380,14 @@ public class TestRecovery extends SolrTe
assertEquals(UpdateLog.State.BUFFERING, ulog.getState());
// simulate updates from a leader
- updateJ(jsonAdd(sdoc("id","C1", "_version_","101")), params(SEEN_LEADER,SEEN_LEADER_VAL));
- updateJ(jsonAdd(sdoc("id","C2", "_version_","102")), params(SEEN_LEADER,SEEN_LEADER_VAL));
- updateJ(jsonAdd(sdoc("id","C3", "_version_","103")), params(SEEN_LEADER,SEEN_LEADER_VAL));
+ updateJ(jsonAdd(sdoc("id","C1", "_version_","101")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
+ updateJ(jsonAdd(sdoc("id","C2", "_version_","102")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
+ updateJ(jsonAdd(sdoc("id","C3", "_version_","103")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
assertTrue(ulog.dropBufferedUpdates());
ulog.bufferUpdates();
- updateJ(jsonAdd(sdoc("id", "C4", "_version_","104")), params(SEEN_LEADER,SEEN_LEADER_VAL));
- updateJ(jsonAdd(sdoc("id", "C5", "_version_","105")), params(SEEN_LEADER,SEEN_LEADER_VAL));
+ updateJ(jsonAdd(sdoc("id", "C4", "_version_","104")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
+ updateJ(jsonAdd(sdoc("id", "C5", "_version_","105")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
logReplay.release(1000);
rinfoFuture = ulog.applyBufferedUpdates();
@@ -395,17 +399,17 @@ public class TestRecovery extends SolrTe
);
// this time add some docs first before buffering starts (so tlog won't be at pos 0)
- updateJ(jsonAdd(sdoc("id","C100", "_version_","200")), params(SEEN_LEADER,SEEN_LEADER_VAL));
- updateJ(jsonAdd(sdoc("id","C101", "_version_","201")), params(SEEN_LEADER,SEEN_LEADER_VAL));
+ updateJ(jsonAdd(sdoc("id","C100", "_version_","200")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
+ updateJ(jsonAdd(sdoc("id","C101", "_version_","201")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
ulog.bufferUpdates();
- updateJ(jsonAdd(sdoc("id","C103", "_version_","203")), params(SEEN_LEADER,SEEN_LEADER_VAL));
- updateJ(jsonAdd(sdoc("id","C104", "_version_","204")), params(SEEN_LEADER,SEEN_LEADER_VAL));
+ updateJ(jsonAdd(sdoc("id","C103", "_version_","203")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
+ updateJ(jsonAdd(sdoc("id","C104", "_version_","204")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
assertTrue(ulog.dropBufferedUpdates());
ulog.bufferUpdates();
- updateJ(jsonAdd(sdoc("id","C105", "_version_","205")), params(SEEN_LEADER,SEEN_LEADER_VAL));
- updateJ(jsonAdd(sdoc("id","C106", "_version_","206")), params(SEEN_LEADER,SEEN_LEADER_VAL));
+ updateJ(jsonAdd(sdoc("id","C105", "_version_","205")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
+ updateJ(jsonAdd(sdoc("id","C106", "_version_","206")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
rinfoFuture = ulog.applyBufferedUpdates();
rinfo = rinfoFuture.get();
@@ -428,14 +432,14 @@ public class TestRecovery extends SolrTe
ulog.bufferUpdates();
assertEquals(UpdateLog.State.BUFFERING, ulog.getState());
- updateJ(jsonAdd(sdoc("id","C301", "_version_","998")), params(SEEN_LEADER,SEEN_LEADER_VAL));
- updateJ(jsonAdd(sdoc("id","C302", "_version_","999")), params(SEEN_LEADER,SEEN_LEADER_VAL));
+ updateJ(jsonAdd(sdoc("id","C301", "_version_","998")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
+ updateJ(jsonAdd(sdoc("id","C302", "_version_","999")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
assertTrue(ulog.dropBufferedUpdates());
// make sure we can overwrite with a lower version
// TODO: is this functionality needed?
- updateJ(jsonAdd(sdoc("id","C301", "_version_","301")), params(SEEN_LEADER,SEEN_LEADER_VAL));
- updateJ(jsonAdd(sdoc("id","C302", "_version_","302")), params(SEEN_LEADER,SEEN_LEADER_VAL));
+ updateJ(jsonAdd(sdoc("id","C301", "_version_","301")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
+ updateJ(jsonAdd(sdoc("id","C302", "_version_","302")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
assertU(commit());
@@ -451,7 +455,7 @@ public class TestRecovery extends SolrTe
);
- updateJ(jsonAdd(sdoc("id","C2", "_version_","302")), params(SEEN_LEADER,SEEN_LEADER_VAL));
+ updateJ(jsonAdd(sdoc("id","C2", "_version_","302")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
@@ -494,9 +498,9 @@ public class TestRecovery extends SolrTe
ulog.bufferUpdates();
// simulate updates from a leader
- updateJ(jsonAdd(sdoc("id","Q1", "_version_","101")), params(SEEN_LEADER,SEEN_LEADER_VAL));
- updateJ(jsonAdd(sdoc("id","Q2", "_version_","102")), params(SEEN_LEADER,SEEN_LEADER_VAL));
- updateJ(jsonAdd(sdoc("id","Q3", "_version_","103")), params(SEEN_LEADER,SEEN_LEADER_VAL));
+ updateJ(jsonAdd(sdoc("id","Q1", "_version_","101")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
+ updateJ(jsonAdd(sdoc("id","Q2", "_version_","102")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
+ updateJ(jsonAdd(sdoc("id","Q3", "_version_","103")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
assertEquals(UpdateLog.State.BUFFERING, ulog.getState());
req.close();
@@ -526,9 +530,9 @@ public class TestRecovery extends SolrTe
assertTrue((ulog.getStartingOperation() & UpdateLog.FLAG_GAP) != 0);
// now do some normal non-buffered adds
- updateJ(jsonAdd(sdoc("id","Q4", "_version_","114")), params(SEEN_LEADER,SEEN_LEADER_VAL));
- updateJ(jsonAdd(sdoc("id","Q5", "_version_","115")), params(SEEN_LEADER,SEEN_LEADER_VAL));
- updateJ(jsonAdd(sdoc("id","Q6", "_version_","116")), params(SEEN_LEADER,SEEN_LEADER_VAL));
+ updateJ(jsonAdd(sdoc("id","Q4", "_version_","114")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
+ updateJ(jsonAdd(sdoc("id","Q5", "_version_","115")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
+ updateJ(jsonAdd(sdoc("id","Q6", "_version_","116")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
assertU(commit());
req.close();
@@ -816,9 +820,9 @@ public class TestRecovery extends SolrTe
// Now test that the bad log file doesn't mess up retrieving latest versions
//
- updateJ(jsonAdd(sdoc("id","F4", "_version_","104")), params(SEEN_LEADER,SEEN_LEADER_VAL));
- updateJ(jsonAdd(sdoc("id","F5", "_version_","105")), params(SEEN_LEADER,SEEN_LEADER_VAL));
- updateJ(jsonAdd(sdoc("id","F6", "_version_","106")), params(SEEN_LEADER,SEEN_LEADER_VAL));
+ updateJ(jsonAdd(sdoc("id","F4", "_version_","104")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
+ updateJ(jsonAdd(sdoc("id","F5", "_version_","105")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
+ updateJ(jsonAdd(sdoc("id","F6", "_version_","106")), params(DISTRIB_UPDATE_PARAM,FROM_LEADER));
// This currently skips the bad log file and also returns the version of the clearIndex (del *:*)
// assertJQ(req("qt","/get", "getVersions","6"), "/versions==[106,105,104]");
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/spelling/IndexBasedSpellCheckerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/spelling/IndexBasedSpellCheckerTest.java?rev=1343567&r1=1343566&r2=1343567&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/spelling/IndexBasedSpellCheckerTest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/spelling/IndexBasedSpellCheckerTest.java Tue May 29 07:18:15 2012
@@ -27,6 +27,7 @@ import org.apache.lucene.index.IndexWrit
import org.apache.lucene.search.spell.JaroWinklerDistance;
import org.apache.lucene.search.spell.SpellChecker;
import org.apache.lucene.search.spell.StringDistance;
+import org.apache.lucene.search.spell.SuggestMode;
import org.apache.lucene.search.spell.SuggestWord;
import org.apache.lucene.search.spell.SuggestWordFrequencyComparator;
import org.apache.lucene.store.Directory;
@@ -199,7 +200,7 @@ public class IndexBasedSpellCheckerTest
IndexReader reader = searcher.getIndexReader();
Collection<Token> tokens = queryConverter.convert("documemt");
- SpellingOptions spellOpts = new SpellingOptions(tokens, reader, 1, false, true, 0.5f, null);
+ SpellingOptions spellOpts = new SpellingOptions(tokens, reader, 1, SuggestMode.SUGGEST_WHEN_NOT_IN_INDEX, true, 0.5f, null);
SpellingResult result = checker.getSuggestions(spellOpts);
assertTrue("result is null and it shouldn't be", result != null);
//should be lowercased, b/c we are using a lowercasing analyzer
@@ -312,7 +313,7 @@ public class IndexBasedSpellCheckerTest
IndexReader reader = searcher.getIndexReader();
Collection<Token> tokens = queryConverter.convert("flesh");
- SpellingOptions spellOpts = new SpellingOptions(tokens, reader, 1, false, true, 0.5f, null);
+ SpellingOptions spellOpts = new SpellingOptions(tokens, reader, 1, SuggestMode.SUGGEST_WHEN_NOT_IN_INDEX, true, 0.5f, null);
SpellingResult result = checker.getSuggestions(spellOpts);
assertTrue("result is null and it shouldn't be", result != null);
//should be lowercased, b/c we are using a lowercasing analyzer
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/spelling/SpellCheckCollatorTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/spelling/SpellCheckCollatorTest.java?rev=1343567&r1=1343566&r2=1343567&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/spelling/SpellCheckCollatorTest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/spelling/SpellCheckCollatorTest.java Tue May 29 07:18:15 2012
@@ -40,7 +40,7 @@ import org.junit.Test;
public class SpellCheckCollatorTest extends SolrTestCaseJ4 {
@BeforeClass
public static void beforeClass() throws Exception {
- initCore("solrconfig.xml", "schema.xml");
+ initCore("solrconfig-spellcheckcomponent.xml", "schema.xml");
assertNull(h.validateUpdate(adoc("id", "0", "lowerfilt", "faith hope and love")));
assertNull(h.validateUpdate(adoc("id", "1", "lowerfilt", "faith hope and loaves")));
assertNull(h.validateUpdate(adoc("id", "2", "lowerfilt", "fat hops and loaves")));
@@ -48,6 +48,12 @@ public class SpellCheckCollatorTest exte
assertNull(h.validateUpdate(adoc("id", "4", "lowerfilt", "fat of homer")));
assertNull(h.validateUpdate(adoc("id", "5", "lowerfilt1", "peace")));
assertNull(h.validateUpdate(adoc("id", "6", "lowerfilt", "hyphenated word")));
+ assertNull(h.validateUpdate(adoc("id", "7", "teststop", "Jane filled out a form at Charles De Gaulle")));
+ assertNull(h.validateUpdate(adoc("id", "8", "teststop", "Dick flew from Heathrow")));
+ assertNull(h.validateUpdate(adoc("id", "9", "teststop", "Jane is stuck in customs because Spot chewed up the form")));
+ assertNull(h.validateUpdate(adoc("id", "10", "teststop", "Once in Paris Dick built a fire on the hearth")));
+ assertNull(h.validateUpdate(adoc("id", "11", "teststop", "Dick waited for Jane as he watched the sparks flow upward")));
+ assertNull(h.validateUpdate(adoc("id", "12", "teststop", "This June parisian rendez-vous is ruined because of a customs snafu")));
assertNull(h.validateUpdate(commit()));
}
@@ -324,4 +330,62 @@ public class SpellCheckCollatorTest exte
List<String> collations = suggestions.getAll("collation");
assertTrue(collations.size() == 1);
}
+
+ @Test
+ public void testContextSensitiveCollate() throws Exception {
+ // DirectSolrSpellChecker IndexBasedSpellChecker
+ String[] dictionary = {"direct", "default_teststop" };
+ for(int i=0 ; i<1 ; i++) {
+ assertQ(
+ req(
+ "q", "teststop:(flew AND form AND heathrow)",
+ "qt", "spellCheckCompRH",
+ "indent", "true",
+ SpellCheckComponent.COMPONENT_NAME, "true",
+ SpellCheckComponent.SPELLCHECK_DICT, dictionary[i],
+ SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS, "true",
+ SpellCheckComponent.SPELLCHECK_COUNT, "10",
+ SpellCheckComponent.SPELLCHECK_ALTERNATIVE_TERM_COUNT, "5",
+ SpellCheckComponent.SPELLCHECK_MAX_RESULTS_FOR_SUGGEST, "0",
+ SpellCheckComponent.SPELLCHECK_COLLATE, "true",
+ SpellCheckComponent.SPELLCHECK_MAX_COLLATION_TRIES, "10",
+ SpellCheckComponent.SPELLCHECK_MAX_COLLATIONS, "1",
+ SpellCheckComponent.SPELLCHECK_COLLATE_EXTENDED_RESULTS, "true"
+ ),
+ "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='flew']/arr[@name='suggestion']/lst/str[@name='word']='flow'",
+ "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='form']/arr[@name='suggestion']/lst/str[@name='word']='from'",
+/* DirectSolrSpellChecker won't suggest if the edit distance > 2, so we can't test for this one...
+ "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='heathrow']/arr[@name='suggestion']/lst/str[@name='word']='hearth'",
+*/
+ "//lst[@name='spellcheck']/lst[@name='suggestions']/bool[@name='correctlySpelled']='false'",
+ "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='collation']/str[@name='collationQuery']='teststop:(flew AND from AND heathrow)'",
+ "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='collation']/int[@name='hits']=1",
+ "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='collation']/lst[@name='misspellingsAndCorrections']/str[@name='form']='from'"
+ );
+
+ assertQ(
+ req(
+ "q", "teststop:(june AND customs)",
+ "qt", "spellCheckCompRH",
+ "indent", "true",
+ SpellCheckComponent.COMPONENT_NAME, "true",
+ SpellCheckComponent.SPELLCHECK_DICT, dictionary[i],
+ SpellCheckComponent.SPELLCHECK_EXTENDED_RESULTS, "true",
+ SpellCheckComponent.SPELLCHECK_COUNT, "10",
+ SpellCheckComponent.SPELLCHECK_ALTERNATIVE_TERM_COUNT, "5",
+ SpellCheckComponent.SPELLCHECK_MAX_RESULTS_FOR_SUGGEST, "1",
+ SpellCheckComponent.SPELLCHECK_COLLATE, "true",
+ SpellCheckComponent.SPELLCHECK_MAX_COLLATION_TRIES, "10",
+ SpellCheckComponent.SPELLCHECK_MAX_COLLATIONS, "1",
+ SpellCheckComponent.SPELLCHECK_COLLATE_EXTENDED_RESULTS, "true"
+ ),
+ "//result[@numFound=1]",
+ "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='june']/arr[@name='suggestion']/lst/str[@name='word']='jane'",
+ "//lst[@name='spellcheck']/lst[@name='suggestions']/bool[@name='correctlySpelled']='false'",
+ "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='collation']/str[@name='collationQuery']='teststop:(jane AND customs)'",
+ "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='collation']/int[@name='hits']=1",
+ "//lst[@name='spellcheck']/lst[@name='suggestions']/lst[@name='collation']/lst[@name='misspellingsAndCorrections']/str[@name='june']='jane'"
+ );
+ }
+ }
}
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/update/PeerSyncTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/update/PeerSyncTest.java?rev=1343567&r1=1343566&r2=1343567&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/update/PeerSyncTest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/update/PeerSyncTest.java Tue May 29 07:18:15 2012
@@ -28,9 +28,15 @@ import org.apache.solr.common.params.Mod
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.StrUtils;
+import static org.apache.solr.update.processor.DistributingUpdateProcessorFactory.DISTRIB_UPDATE_PARAM;
+import static org.apache.solr.update.processor.DistributedUpdateProcessor.DistribPhase;
+
public class PeerSyncTest extends BaseDistributedSearchTestCase {
private static int numVersions = 100; // number of versions to use when syncing
- private ModifiableSolrParams seenLeader = params("leader","true");
+ private final String FROM_LEADER = DistribPhase.FROMLEADER.toString();
+
+ private ModifiableSolrParams seenLeader =
+ params(DISTRIB_UPDATE_PARAM, FROM_LEADER);
public PeerSyncTest() {
fixShardCount = true;
@@ -112,9 +118,9 @@ public class PeerSyncTest extends BaseDi
v=1000;
add(client0, seenLeader, sdoc("id","1000","_version_",++v));
add(client0, seenLeader, sdoc("id","1001","_version_",++v));
- delQ(client0, params("leader","true","_version_",Long.toString(-++v)), "id:1001 OR id:1002");
+ delQ(client0, params(DISTRIB_UPDATE_PARAM,FROM_LEADER,"_version_",Long.toString(-++v)), "id:1001 OR id:1002");
add(client0, seenLeader, sdoc("id","1002","_version_",++v));
- del(client0, params("leader","true","_version_",Long.toString(-++v)), "1000");
+ del(client0, params(DISTRIB_UPDATE_PARAM,FROM_LEADER,"_version_",Long.toString(-++v)), "1000");
assertSync(client1, numVersions, true, shardsArr[0]);
client0.commit(); client1.commit(); queryAndCompare(params("q", "*:*", "sort","_version_ desc"), client0, client1);
@@ -124,18 +130,18 @@ public class PeerSyncTest extends BaseDi
SolrServer client = client0;
add(client, seenLeader, sdoc("id","2000","_version_",++v));
add(client, seenLeader, sdoc("id","2001","_version_",++v));
- delQ(client, params("leader","true","_version_",Long.toString(-++v)), "id:2001 OR id:2002");
+ delQ(client, params(DISTRIB_UPDATE_PARAM,FROM_LEADER,"_version_",Long.toString(-++v)), "id:2001 OR id:2002");
add(client, seenLeader, sdoc("id","2002","_version_",++v));
- del(client, params("leader","true","_version_",Long.toString(-++v)), "2000");
+ del(client, params(DISTRIB_UPDATE_PARAM,FROM_LEADER,"_version_",Long.toString(-++v)), "2000");
v=2000;
client = client1;
add(client, seenLeader, sdoc("id","2000","_version_",++v));
++v; // pretend we missed the add of 2001. peersync should retrieve it, but should also retrieve any deleteByQuery objects after it
// add(client, seenLeader, sdoc("id","2001","_version_",++v));
- delQ(client, params("leader","true","_version_",Long.toString(-++v)), "id:2001 OR id:2002");
+ delQ(client, params(DISTRIB_UPDATE_PARAM,FROM_LEADER,"_version_",Long.toString(-++v)), "id:2001 OR id:2002");
add(client, seenLeader, sdoc("id","2002","_version_",++v));
- del(client, params("leader","true","_version_",Long.toString(-++v)), "2000");
+ del(client, params(DISTRIB_UPDATE_PARAM,FROM_LEADER,"_version_",Long.toString(-++v)), "2000");
assertSync(client1, numVersions, true, shardsArr[0]);
client0.commit(); client1.commit(); queryAndCompare(params("q", "*:*", "sort","_version_ desc"), client0, client1);
@@ -149,12 +155,12 @@ public class PeerSyncTest extends BaseDi
// the reorder in application shouldn't affect anything
add(client0, seenLeader, sdoc("id","3000","_version_",3001));
add(client1, seenLeader, sdoc("id","3000","_version_",3001));
- del(client0, params("leader","true","_version_","3000"), "3000");
+ del(client0, params(DISTRIB_UPDATE_PARAM,FROM_LEADER,"_version_","3000"), "3000");
// this should cause us to retrieve an add tha was previously deleted
add(client0, seenLeader, sdoc("id","3001","_version_",3003));
- del(client0, params("leader","true","_version_","3001"), "3004");
- del(client1, params("leader","true","_version_","3001"), "3004");
+ del(client0, params(DISTRIB_UPDATE_PARAM,FROM_LEADER,"_version_","3001"), "3004");
+ del(client1, params(DISTRIB_UPDATE_PARAM,FROM_LEADER,"_version_","3001"), "3004");
// this should cause us to retrieve an older add that was overwritten
add(client0, seenLeader, sdoc("id","3002","_version_",3004));
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/update/TestUpdate.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/update/TestUpdate.java?rev=1343567&r1=1343566&r2=1343567&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/update/TestUpdate.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/update/TestUpdate.java Tue May 29 07:18:15 2012
@@ -44,7 +44,6 @@ import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import static org.apache.solr.core.SolrCore.verbose;
-import static org.apache.solr.update.processor.DistributedUpdateProcessor.SEEN_LEADER;
public class TestUpdate extends SolrTestCaseJ4 {
@BeforeClass
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/update/processor/CustomUpdateRequestProcessorFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/update/processor/CustomUpdateRequestProcessorFactory.java?rev=1343567&r1=1343566&r2=1343567&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/update/processor/CustomUpdateRequestProcessorFactory.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/update/processor/CustomUpdateRequestProcessorFactory.java Tue May 29 07:18:15 2012
@@ -39,8 +39,7 @@ public class CustomUpdateRequestProcesso
@Override
public UpdateRequestProcessor getInstance(SolrQueryRequest req, SolrQueryResponse rsp, UpdateRequestProcessor next) {
- // TODO Auto-generated method stub
- return null;
+ return new CustomUpdateRequestProcessor(next);
}
}
Modified: lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/update/processor/UpdateRequestProcessorFactoryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/update/processor/UpdateRequestProcessorFactoryTest.java?rev=1343567&r1=1343566&r2=1343567&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/update/processor/UpdateRequestProcessorFactoryTest.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/core/src/test/org/apache/solr/update/processor/UpdateRequestProcessorFactoryTest.java Tue May 29 07:18:15 2012
@@ -1,4 +1,4 @@
-/**
+/*
* 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.
@@ -18,9 +18,15 @@
package org.apache.solr.update.processor;
import org.apache.solr.core.SolrCore;
+import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.update.processor.UpdateRequestProcessorChain;
+import org.apache.solr.update.processor.CustomUpdateRequestProcessor;
import org.apache.solr.util.AbstractSolrTestCase;
+import java.util.Arrays;
+
+import static org.apache.solr.update.processor.DistributingUpdateProcessorFactory.DISTRIB_UPDATE_PARAM;
+
/**
*
*/
@@ -52,4 +58,37 @@ public class UpdateRequestProcessorFacto
// Make sure the NamedListArgs got through ok
assertEquals( "{name={n8=88,n9=99}}", link.args.toString() );
}
+
+ public void testUpdateDistribChainSkipping() throws Exception {
+ SolrCore core = h.getCore();
+ for (final String name : Arrays.asList("distrib-chain-explicit",
+ "distrib-chain-implicit",
+ "distrib-chain-noop")) {
+
+ UpdateRequestProcessor proc;
+ UpdateRequestProcessorChain chain = core.getUpdateProcessingChain(name);
+ assertNotNull(name, chain);
+
+ // either explicitly, or because of injection
+ assertEquals(name + " chain length", 4,
+ chain.getFactories().length);
+
+ // Custom comes first in all three of our chains
+ proc = chain.createProcessor(req(), new SolrQueryResponse());
+ assertTrue(name + " first processor isn't a CustomUpdateRequestProcessor: "
+ + proc.getClass().getName(),
+ proc instanceof CustomUpdateRequestProcessor);
+
+ // varies depending on chain, but definitely shouldn't be Custom
+ proc = chain.createProcessor(req(DISTRIB_UPDATE_PARAM, "non_blank_value"),
+ new SolrQueryResponse());
+ assertFalse(name + " post distrib proc should not be a CustomUpdateRequestProcessor: "
+ + proc.getClass().getName(),
+ proc instanceof CustomUpdateRequestProcessor);
+
+
+ }
+
+ }
+
}
Modified: lucene/dev/branches/LUCENE-2878/solr/example/example-DIH/solr/mail/conf/data-config.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/example/example-DIH/solr/mail/conf/data-config.xml?rev=1343567&r1=1343566&r2=1343567&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/example/example-DIH/solr/mail/conf/data-config.xml (original)
+++ lucene/dev/branches/LUCENE-2878/solr/example/example-DIH/solr/mail/conf/data-config.xml Tue May 29 07:18:15 2012
@@ -6,6 +6,7 @@
-->
<entity processor="MailEntityProcessor" user="email@gmail.com"
password="password" host="imap.gmail.com" protocol="imaps"
- fetchMailsSince="2009-09-20 00:00:00" batchSize="20" folders="inbox" processAttachement="false"/>
+ fetchMailsSince="2009-09-20 00:00:00" batchSize="20" folders="inbox" processAttachement="false"
+ name="sample_entity"/>
</document>
</dataConfig>
Modified: lucene/dev/branches/LUCENE-2878/solr/example/solr/conf/solrconfig.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/example/solr/conf/solrconfig.xml?rev=1343567&r1=1343566&r2=1343567&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/example/solr/conf/solrconfig.xml (original)
+++ lucene/dev/branches/LUCENE-2878/solr/example/solr/conf/solrconfig.xml Tue May 29 07:18:15 2012
@@ -976,7 +976,7 @@
http://wiki.apache.org/solr/AnalysisRequestHandler
An analysis handler that provides a breakdown of the analysis
- process of provided docuemnts. This handler expects a (single)
+ process of provided documents. This handler expects a (single)
content stream with the following format:
<docs>
Modified: lucene/dev/branches/LUCENE-2878/solr/solrj/src/java/org/apache/solr/client/solrj/impl/XMLResponseParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/solrj/src/java/org/apache/solr/client/solrj/impl/XMLResponseParser.java?rev=1343567&r1=1343566&r2=1343567&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/solrj/src/java/org/apache/solr/client/solrj/impl/XMLResponseParser.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/solrj/src/java/org/apache/solr/client/solrj/impl/XMLResponseParser.java Tue May 29 07:18:15 2012
@@ -414,8 +414,12 @@ public class XMLResponseParser extends R
doc.addField( name, val );
}
depth--; // the array reading clears out the 'endElement'
- }
- else if( !type.isLeaf ) {
+ } else if( type == KnownType.LST ) {
+ doc.addField( name, readNamedList( parser ) );
+ depth--;
+ } else if( !type.isLeaf ) {
+ System.out.println("nbot leaf!:" + type);
+
throw new XMLStreamException( "must be value or array", parser.getLocation() );
}
break;
Modified: lucene/dev/branches/LUCENE-2878/solr/solrj/src/java/org/apache/solr/common/params/SpellingParams.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/solrj/src/java/org/apache/solr/common/params/SpellingParams.java?rev=1343567&r1=1343566&r2=1343567&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/solrj/src/java/org/apache/solr/common/params/SpellingParams.java (original)
+++ lucene/dev/branches/LUCENE-2878/solr/solrj/src/java/org/apache/solr/common/params/SpellingParams.java Tue May 29 07:18:15 2012
@@ -33,14 +33,39 @@ public interface SpellingParams {
public static final String SPELLCHECK_DICT = SPELLCHECK_PREFIX + "dictionary";
/**
- * The count of suggestions needed for a given query.
+ * The count of suggestions to return for each query term not in the index and/or dictionary.
* <p/>
* If this parameter is absent in the request then only one suggestion is
* returned. If it is more than one then a maximum of given suggestions are
* returned for each token in the query.
*/
public static final String SPELLCHECK_COUNT = SPELLCHECK_PREFIX + "count";
-
+
+ /**
+ * The count of suggestions to return for each query term existing in the index and/or dictionary.
+ * <p/>
+ * If this parameter is absent in the request then no suggestions are generated. This parameter allows
+ * for receiving alternative terms to use in context-sensitive spelling corrections.
+ */
+ public static final String SPELLCHECK_ALTERNATIVE_TERM_COUNT = SPELLCHECK_PREFIX + "alternativeTermCount";
+
+ /**
+ * <p>
+ * The maximum number of hits the request can return in order to both
+ * generate spelling suggestions and set the "correctlySpelled" element to "false".
+ * Note that this parameter is typically of use only in conjunction with "spellcheck.alternativeTermCount".
+ * </p>
+ * <p>
+ * If left unspecified, the default behavior will prevail. That is, "correctlySpelled" will be false and suggestions
+ * will be returned only if one or more of the query terms are absent from the dictionary and/or index. If set to zero,
+ * the "correctlySpelled" flag will be false only if the response returns zero hits. If set to a value greater than zero,
+ * suggestions will be returned even if hits are returned (up to the specified number). This number also will serve as
+ * the threshold in determining the value of "correctlySpelled". Specifying a value greater than zero is useful
+ * for creating "did-you-mean" suggestions for queries that return a low number of hits.
+ * </p>
+ */
+ public static final String SPELLCHECK_MAX_RESULTS_FOR_SUGGEST = SPELLCHECK_PREFIX + "maxResultsForSuggest";
+
/**
* When this parameter is set to true and the misspelled word exists in the
* user field, only words that occur more frequently in the Solr field than
@@ -49,7 +74,7 @@ public interface SpellingParams {
* <b>This is applicable only for dictionaries built from Solr fields.</b>
*/
public static final String SPELLCHECK_ONLY_MORE_POPULAR = SPELLCHECK_PREFIX + "onlyMorePopular";
-
+
/**
* Whether to use the extended response format, which is more complicated but
* richer. Returns the document frequency for each suggestion and returns one
Modified: lucene/dev/branches/LUCENE-2878/solr/testlogging.properties
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/testlogging.properties?rev=1343567&r1=1343566&r2=1343567&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/testlogging.properties (original)
+++ lucene/dev/branches/LUCENE-2878/solr/testlogging.properties Tue May 29 07:18:15 2012
@@ -4,11 +4,12 @@ java.util.logging.ConsoleHandler.level=F
java.util.logging.ConsoleHandler.formatter=org.apache.solr.SolrLogFormatter
-.level=SEVERE
-#.level=INFO
+#.level=SEVERE
+.level=INFO
#org.apache.solr.update.processor.LogUpdateProcessor=FINEST
#org.apache.solr.update.processor.DistributedUpdateProcessor=FINEST
#org.apache.solr.update.PeerSync.level=FINEST
#org.apache.solr.update.UpdateLog.level=FINE
#org.apache.solr.update.TransactionLog.level=FINEST
+
Modified: lucene/dev/branches/LUCENE-2878/solr/webapp/web/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/solr/webapp/web/WEB-INF/web.xml?rev=1343567&r1=1343566&r2=1343567&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/solr/webapp/web/WEB-INF/web.xml (original)
+++ lucene/dev/branches/LUCENE-2878/solr/webapp/web/WEB-INF/web.xml Tue May 29 07:18:15 2012
@@ -15,13 +15,14 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5"
metadata-complete="true"
>
+
<!-- Uncomment if you are trying to use a Resin version before 3.0.19.
Their XML implementation isn't entirely compatible with Xerces.
Below are the implementations to use with Sun's JVM.