Skip to content

Commit

Permalink
aaaaargh, the solr upgrade is hard
Browse files Browse the repository at this point in the history
  • Loading branch information
romanchyla committed Jun 17, 2014
1 parent c06fbad commit 7193b64
Show file tree
Hide file tree
Showing 21 changed files with 161 additions and 141 deletions.
30 changes: 24 additions & 6 deletions .classpath
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="lib" path="build/solrjars-extracted/lucene-test-framework-4.8-SNAPSHOT.jar" sourcepath="build/solr-download/apache-solr-4.0.0-SVN/lucene/test-framework/src/java"/>
<classpathentry kind="lib" path="build/solrjars-extracted/solr-test-framework-4.8-SNAPSHOT.jar" sourcepath="build/solr-download/apache-solr-4.0.0-SVN/solr/test-framework/src/java"/>
<classpathentry kind="src" path="contrib/antlrqueryparser/src/java"/>
<classpathentry kind="src" path="contrib/adsabs/src/jython"/>
<classpathentry kind="src" path="contrib/antlrqueryparser/src/test"/>
Expand All @@ -15,7 +17,6 @@
<classpathentry kind="lib" path="contrib/antlrqueryparser/lib/antlr-3.4-complete.jar"/>
<classpathentry kind="lib" path="contrib/adsabs/lib/jython-standalone-2.7-b1.jar" sourcepath="contrib/adsabs/lib/jython-2.7-b1-sources.jar"/>
<classpathentry kind="lib" path="lib/luke-4.0.0-BETA.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/apache-solr-4.0.0-SVN"/>
<classpathentry kind="lib" path="build/solrjars-extracted/solrj-lib/commons-io-2.1.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/solrj-lib/slf4j-api-1.7.6.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/solrj-lib/slf4j-log4j12-1.7.6.jar"/>
Expand Down Expand Up @@ -65,23 +66,21 @@
<classpathentry kind="lib" path="build/solrjars-extracted/lucene-sandbox-4.8-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/lucene-spatial-4.8-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/lucene-suggest-4.8-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/lucene-test-framework-4.8-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/noggit-0.5.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/org.restlet-2.1.1.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/org.restlet.ext.servlet-2.1.1.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/protobuf-java-2.5.0.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/solr-analysis-extras-4.8-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/solr-cell-4.8-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/solr-clustering-4.8-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/solr-core-4.8-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/solr-dataimporthandler-4.8-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/solr-core-4.8-SNAPSHOT.jar" sourcepath="build/solr-download/apache-solr-4.0.0-SVN/solr/core/src/java"/>
<classpathentry kind="lib" path="build/solrjars-extracted/solr-dataimporthandler-4.8-SNAPSHOT.jar" sourcepath="build/solr-download/apache-solr-4.0.0-SVN/solr/contrib/dataimporthandler/src"/>
<classpathentry kind="lib" path="build/solrjars-extracted/solr-dataimporthandler-extras-4.8-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/solr-langid-4.8-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/solr-map-reduce-4.8-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/solr-morphlines-cell-4.8-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/solr-morphlines-core-4.8-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/solr-solrj-4.8-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/solr-test-framework-4.8-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/solr-uima-4.8-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/solr-velocity-4.8-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/spatial4j-0.4.1.jar"/>
Expand All @@ -92,6 +91,25 @@
<classpathentry kind="lib" path="build/solrjars-extracted/test-framework/lib/randomizedtesting-runner-2.1.3.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/test-framework/lucene-libs/lucene-test-framework-4.8-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/solrj-lib/noggit-0.5.jar"/>
<classpathentry kind="lib" path="/apache-solr-4.0.0-SVN/solr/solrj/lib/noggit-0.5.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/solrj-lib/log4j-1.2.16.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/solrj-lib/jcl-over-slf4j-1.7.6.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/solrj-lib/jul-to-slf4j-1.7.6.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/solrj-lib/httpclient-4.3.1.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/solrj-lib/httpcore-4.3.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/solrj-lib/httpmime-4.3.1.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/solrj-lib/wstx-asl-3.2.7.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/solrj-lib/zookeeper-3.4.6.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/example-lib/jetty-continuation-8.1.10.v20130312.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/example-lib/jetty-deploy-8.1.10.v20130312.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/example-lib/jetty-http-8.1.10.v20130312.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/example-lib/jetty-io-8.1.10.v20130312.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/example-lib/jetty-jmx-8.1.10.v20130312.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/example-lib/jetty-security-8.1.10.v20130312.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/example-lib/jetty-server-8.1.10.v20130312.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/example-lib/jetty-servlet-8.1.10.v20130312.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/example-lib/jetty-util-8.1.10.v20130312.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/example-lib/jetty-webapp-8.1.10.v20130312.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/example-lib/jetty-xml-8.1.10.v20130312.jar"/>
<classpathentry kind="lib" path="build/solrjars-extracted/example-lib/servlet-api-3.0.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
17 changes: 17 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>montysolr-next</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
7 changes: 7 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,13 @@ montysolr.version=${montysolr.version}
</fileset>
</copy>

<!-- this is required for running tests (that load jetty) -->
<copy todir="${build.dir}/solrjars-extracted/example-lib" flatten="false">
<fileset dir="${solr.real.location}/example/lib">
<include name="**/**.jar"/>
</fileset>
</copy>

</target>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
public class NewSynonymFilterFactory extends TokenFilterFactory implements ResourceLoaderAware {
protected Map<String,String> args;

protected NewSynonymFilterFactory(Map<String,String> args) {
public NewSynonymFilterFactory(Map<String,String> args) {
super(args);
this.args = args;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,23 @@ protected QueryNode postProcessNode(QueryNode node)
// first parse the date with the appropriate analyzer
String value = fieldNode.getTextAsString();
Analyzer analyzer = getQueryConfigHandler().get(ConfigurationKeys.ANALYZER);
TokenStream source;
TokenStream source = null;
try {
source = analyzer.tokenStream(field, new StringReader(value));
source.reset();
source.incrementToken();
} catch (IOException e1) {
throw new RuntimeException(e1);
}
finally {
if (source != null) {
try {
source.close();
} catch (IOException e) {
// ignore
}
}
}

Date date = null;
String normalizedDate=null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*
*/
public class ASCIIDuplicatingFilterFactory extends TokenFilterFactory implements MultiTermAwareComponent {
protected ASCIIDuplicatingFilterFactory(Map<String,String> args) {
public ASCIIDuplicatingFilterFactory(Map<String,String> args) {
super(args);
if (!args.isEmpty()) {
throw new IllegalArgumentException("Unknown parameter(s): " + args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public static class MakeAllShortNames extends NewSynonymFilterFactory.SynonymBui



protected MakeAllShortNames(Map<String,String> args) {
public MakeAllShortNames(Map<String,String> args) {
super(args);
}

Expand Down Expand Up @@ -292,7 +292,7 @@ private int containsLongForm(String[] names) {
*/
public static class MakeShortNames extends NewSynonymFilterFactory.SynonymBuilderFactory {

protected MakeShortNames(Map<String,String> args) {
public MakeShortNames(Map<String,String> args) {
super(args);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public int incrementId() {
}


public String[] formatSynonyms(String[] strings) {
public static String[] formatSynonyms(String[] strings) {
String[] newLines = new String[strings.length];
int nl = 0;
for (String line : strings) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package org.apache.solr.analysis;

import java.io.StringReader;
import java.util.HashMap;
import java.util.Map;

import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.BaseTokenStreamTestCase;
Expand All @@ -9,7 +12,7 @@
public class TestASCIIDuplicatingFilter extends BaseTokenStreamTestCase {

public void test() throws Exception {
ASCIIDuplicatingFilterFactory factory = new ASCIIDuplicatingFilterFactory();
ASCIIDuplicatingFilterFactory factory = new ASCIIDuplicatingFilterFactory(new HashMap<String,String>());

TokenStream stream = factory.create(new MockTokenizer(new StringReader("čtyřista čtyřicet čtyři"),
MockTokenizer.WHITESPACE, false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,33 @@

import org.apache.lucene.search.NumericRangeQuery;
import org.adsabs.solr.AdsConfig.F;
import org.junit.BeforeClass;

/**
* Test for the date_string type
*
*/
public class TestAdsabsTypeDateString extends MontySolrQueryTestCase {

@BeforeClass
public static void beforeClass() throws Exception {

@Override
public String getSchemaFile() {
makeResourcesVisible(this.solrConfig.getResourceLoader(),
new String[] {MontySolrSetup.getMontySolrHome() + "/contrib/examples/adsabs/solr/collection1/conf",
MontySolrSetup.getSolrHome() + "/example/solr/collection1/conf"
});
return MontySolrSetup.getMontySolrHome()
+ "/contrib/examples/adsabs/solr/collection1/conf/schema.xml";
makeResourcesVisible(Thread.currentThread().getContextClassLoader(), new String[] {
MontySolrSetup.getMontySolrHome() + "/contrib/examples/adsabs/solr/collection1/conf",
MontySolrSetup.getSolrHome() + "/example/solr/collection1/conf"
});

}
System.setProperty("solr.allow.unsafe.resourceloading", "true");
schemaString = MontySolrSetup.getMontySolrHome()
+ "/contrib/examples/adsabs/solr/collection1/conf/schema.xml";

public String getSolrConfigFile() {
return MontySolrSetup.getMontySolrHome()
+ "/contrib/examples/adsabs/solr/collection1/conf/solrconfig.xml";
}
configString = MontySolrSetup.getMontySolrHome()
+ "/contrib/examples/adsabs/solr/collection1/conf/solrconfig.xml";

initCore(configString, schemaString, MontySolrSetup.getSolrHome()
+ "/example/solr");
}



public void test() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.apache.solr.analysis;

import java.io.StringReader;
import java.util.HashMap;

import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.BaseTokenStreamTestCase;
Expand All @@ -9,7 +11,7 @@
public class TestDateNormalizerFilter extends BaseTokenStreamTestCase {

public void test() throws Exception {
ASCIIDuplicatingFilterFactory factory = new ASCIIDuplicatingFilterFactory();
ASCIIDuplicatingFilterFactory factory = new ASCIIDuplicatingFilterFactory(new HashMap<String,String>());

TokenStream stream = factory.create(new MockTokenizer(new StringReader("čtyřista čtyřicet čtyři"),
MockTokenizer.WHITESPACE, false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,27 @@ public class TestAdsabsTypeAuthorParsing extends MontySolrQueryTestCase {
private String author_field = "author";


@Override
public String getSchemaFile() {
makeResourcesVisible(this.solrConfig.getResourceLoader(),
new String[] {MontySolrSetup.getMontySolrHome() + "/contrib/examples/adsabs/solr/collection1/conf",
MontySolrSetup.getSolrHome() + "/example/solr/collection1/conf"
});

@BeforeClass
public static void beforeClass() throws Exception {

makeResourcesVisible(Thread.currentThread().getContextClassLoader(),
new String[] {MontySolrSetup.getMontySolrHome() + "/contrib/examples/adsabs/solr/collection1/conf",
MontySolrSetup.getSolrHome() + "/example/solr/collection1/conf"
});

System.setProperty("solr.allow.unsafe.resourceloading", "true");
schemaString = getSchemaFile();


configString = MontySolrSetup.getMontySolrHome()
+ "/contrib/examples/adsabs/solr/collection1/conf/solrconfig.xml";

initCore(configString, schemaString, MontySolrSetup.getSolrHome()
+ "/example/solr");
}

public static String getSchemaFile() {

/*
* Make a copy of the schema.xml, and create our own synonym translation rules
*/
Expand Down Expand Up @@ -294,27 +308,15 @@ public void setUp() throws Exception {
TokenStream iAuthor = iAnalyzer.tokenStream("author", new StringReader(""));
TokenStream qAuthor = qAnalyzer.tokenStream("author", new StringReader(""));

iAuthor.reset();
iAuthor.reset();
iAuthor.reset();

qAuthor.reset();
qAuthor.reset();
qAuthor.reset();

iAuthor.close();
qAuthor.close();

// TODO: force reload of the synonym map
//h.getCoreContainer().reload("collection1");

}

@Override
public String getSolrConfigFile() {

return MontySolrSetup.getMontySolrHome()
+ "/contrib/examples/adsabs/solr/collection1/conf/solrconfig.xml";

}



public void testAuthorParsingUseCases() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class TestAuthorSynonymFilter extends BaseTokenStreamTestCase {
public void testAuthorSynonyms1() throws Exception {


AuthorSynonymFilterFactory factory = new AuthorSynonymFilterFactory();
AuthorSynonymFilterFactory factory = new AuthorSynonymFilterFactory(new HashMap<String,String>());
WriteableSynonymMap map = new WriteableExplicitSynonymMap();
List<String> rules = new ArrayList<String>();
rules.add("MILLER, WILLIAM=>MILLER, B;MILLER, BILL;MILLER,;MILLER, BILL\\b.*");
Expand Down Expand Up @@ -54,7 +54,7 @@ public void testAuthorSynonyms1() throws Exception {
}
public void testAuthorSynonyms2() throws Exception {

AuthorSynonymFilterFactory factory = new AuthorSynonymFilterFactory();
AuthorSynonymFilterFactory factory = new AuthorSynonymFilterFactory(new HashMap<String,String>());
WriteableSynonymMap map = new WriteableExplicitSynonymMap();
List<String> rules = new ArrayList<String>();

Expand Down Expand Up @@ -106,7 +106,7 @@ public void testAuthorSynonyms2() throws Exception {

public void testAuthorEquivSynonymMap() throws Exception {

AuthorSynonymFilterFactory factory = new AuthorSynonymFilterFactory();
AuthorSynonymFilterFactory factory = new AuthorSynonymFilterFactory(new HashMap<String,String>());
WriteableSynonymMap map = new WriteableEquivalentSynonymMap();
List<String> rules = new ArrayList<String>(){{
add("ADAMČUK\\,\\ K,ADAMCUK\\,\\ K,ADAMCHUK\\,\\ K,");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.util.HashMap;

import org.apache.lucene.analysis.core.KeywordTokenizer;
import org.apache.lucene.analysis.tokenattributes.TypeAttribute;
import org.apache.lucene.analysis.TokenFilter;
Expand Down Expand Up @@ -30,7 +32,7 @@ public void testAuthorSynonyms() throws Exception {
Tokenizer tokenizer = new KeywordTokenizer(reader);


AuthorTransliterationFactory factory = new AuthorTransliterationFactory();
AuthorTransliterationFactory factory = new AuthorTransliterationFactory(new HashMap<String,String>());

TokenStream stream = factory.create(new TestFilter(tokenizer));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.io.Reader;
import java.io.StringReader;
import java.util.HashMap;

import org.apache.lucene.analysis.core.KeywordTokenizer;
import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.TokenStream;
Expand All @@ -12,7 +14,7 @@ public class TestAuthorVariationFilter extends BaseTokenStreamTestCase {
public void testAuthorVariations() throws Exception {
Reader reader = new StringReader("GOMEZ, HECTOR");
Tokenizer tokenizer = new KeywordTokenizer(reader);
AuthorQueryVariationsFilterFactory factory = new AuthorQueryVariationsFilterFactory();
AuthorQueryVariationsFilterFactory factory = new AuthorQueryVariationsFilterFactory(new HashMap<String,String>());
TokenStream stream = factory.create(tokenizer);
String[] expected = { "GOMEZ, HECTOR", "GOMEZ, H", "GOMEZ,", "GOMEZ, HECTOR\\b.*", "GOMEZ, H\\b.*", };
assertTokenStreamContents(stream, expected);
Expand Down
Loading

0 comments on commit 7193b64

Please sign in to comment.