Skip to content

Commit

Permalink
HSEARCH-1501 Removing all references to Apache Solr from our poms and…
Browse files Browse the repository at this point in the history
… code
  • Loading branch information
Sanne authored and hferentschik committed Feb 5, 2014
1 parent 331f915 commit 6e432d3
Show file tree
Hide file tree
Showing 11 changed files with 151 additions and 202 deletions.
4 changes: 2 additions & 2 deletions analyzers/pom.xml
Expand Up @@ -43,8 +43,8 @@
<artifactId>lucene-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-analysis-extras</artifactId>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queryparser</artifactId>
</dependency>
</dependencies>
</project>
5 changes: 5 additions & 0 deletions engine/pom.xml
Expand Up @@ -50,6 +50,11 @@
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queryparser</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
Expand Down
13 changes: 0 additions & 13 deletions engine/src/main/java/org/hibernate/search/impl/ConfigContext.java
Expand Up @@ -88,7 +88,6 @@ public final class ConfigContext {

private final List<DelegateNamedAnalyzer> lazyAnalyzers = new ArrayList<DelegateNamedAnalyzer>();
private final Analyzer defaultAnalyzer;
private final boolean solrPresent;
private final boolean jpaPresent;
private final Version luceneMatchVersion;
private final String nullToken;
Expand All @@ -103,7 +102,6 @@ public ConfigContext(SearchConfiguration cfg) {
public ConfigContext(SearchConfiguration cfg, SearchMapping searchMapping) {
luceneMatchVersion = getLuceneMatchVersion( cfg );
defaultAnalyzer = initAnalyzer( cfg );
solrPresent = isPresent( "org.apache.solr.analysis.TokenizerChain" );
jpaPresent = isPresent( "javax.persistence.Id" );
nullToken = initNullToken( cfg );
implicitProvidedId = cfg.isIdProvidedImplicit();
Expand Down Expand Up @@ -223,17 +221,6 @@ public Map<String, Analyzer> initLazyAnalyzers() {
}

private Analyzer buildAnalyzer(AnalyzerDef analyzerDef) {
if ( !solrPresent ) {
throw new SearchException(
"Use of @AnalyzerDef while Solr is not present in the classpath. Add apache-solr-analyzer.jar"
);
}

// SolrAnalyzerBuilder references Solr classes.
// InitContext should not (directly or indirectly) load a Solr class to avoid hard dependency
// unless necessary
// the current mechanism (check Solr class presence and call SolrAnalyzerBuilder if needed
// seems to be sufficient on Apple VM (derived from Sun's
try {
return SolrAnalyzerBuilder.buildAnalyzer( analyzerDef, luceneMatchVersion );
}
Expand Down
Expand Up @@ -33,7 +33,6 @@
import org.apache.lucene.util.Version;
import org.apache.lucene.analysis.util.CharFilterFactory;
import org.apache.lucene.analysis.util.TokenFilterFactory;
import org.apache.solr.analysis.TokenizerChain;
import org.apache.lucene.analysis.util.TokenizerFactory;
import org.hibernate.search.annotations.AnalyzerDef;
import org.hibernate.search.annotations.CharFilterDef;
Expand Down
90 changes: 90 additions & 0 deletions engine/src/main/java/org/hibernate/search/impl/TokenizerChain.java
@@ -0,0 +1,90 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2014, Red Hat, Inc. and/or its affiliates or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat, Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.search.impl;

import java.io.Reader;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.util.CharFilterFactory;
import org.apache.lucene.analysis.util.TokenFilterFactory;
import org.apache.lucene.analysis.util.TokenizerFactory;

/**
* Inspired by Apache Solr's org.apache.solr.analysis.TokenizerChain.TokenizerChain
*/
public final class TokenizerChain extends Analyzer {

private final CharFilterFactory[] charFilters;
private final TokenizerFactory tokenizer;
private final TokenFilterFactory[] filters;

public TokenizerChain(CharFilterFactory[] charFilters, TokenizerFactory tokenizer, TokenFilterFactory[] filters) {
this.charFilters = charFilters != null ? charFilters : new CharFilterFactory[0];
this.tokenizer = tokenizer;
this.filters = filters != null ? filters : new TokenFilterFactory[0];
}

@Override
public Reader initReader(final String fieldName, final Reader reader) {
if ( charFilters.length > 0 ) {
Reader cs = reader;
for ( CharFilterFactory charFilter : charFilters ) {
cs = charFilter.create( cs );
}
return cs;
}
else {
return reader;
}
}

@Override
protected TokenStreamComponents createComponents(final String fieldName, final Reader aReader) {
Tokenizer tk = tokenizer.create( aReader );
TokenStream ts = tk;
for ( TokenFilterFactory filter : filters ) {
ts = filter.create( ts );
}
return new TokenStreamComponents( tk, ts );
}

@Override
public String toString() {
final StringBuilder sb = new StringBuilder( "TokenizerChain(" );
for ( CharFilterFactory filter : charFilters ) {
sb.append( filter );
sb.append( ", " );
}
sb.append( tokenizer );
for ( TokenFilterFactory filter : filters ) {
sb.append( ", " );
sb.append( filter );
}
sb.append( ')' );
return sb.toString();
}

}
Expand Up @@ -49,7 +49,6 @@
import org.apache.lucene.util.AttributeImpl;
import org.apache.lucene.util.AttributeSource;
import org.apache.lucene.util.BytesRef;
import org.apache.solr.handler.AnalysisRequestHandlerBase;

import org.hibernate.search.SearchException;
import org.hibernate.search.backend.AddLuceneWork;
Expand Down Expand Up @@ -294,14 +293,8 @@ public void addAttributeInstance(AttributeImpl attribute) {

@Override
public void addTokenTrackingAttribute(List<Integer> positions) {
AnalysisRequestHandlerBase.TokenTrackingAttributeImpl attr = new AnalysisRequestHandlerBase.TokenTrackingAttributeImpl();
int size = positions.size() - 1;
int[] basePosition = new int[size];
for ( int index = 0; index < size; index++ ) {
basePosition[index] = positions.get( index );
}
attr.reset( basePosition, positions.get( size ) );
getAttributes().add( attr );
//TokenTrackingAttribute is no longer available
throw new SearchException( "Serialization of TokenTrackingAttribute is no longer supported" );
}

@Override
Expand Down
15 changes: 10 additions & 5 deletions integrationtest/performance/pom.xml
Expand Up @@ -86,11 +86,6 @@
<artifactId>xnio-nio</artifactId>
<version>3.2.0.Final</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.1</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down Expand Up @@ -142,6 +137,16 @@
<version>${wildflyVersion}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
15 changes: 15 additions & 0 deletions orm/pom.xml
Expand Up @@ -56,6 +56,16 @@
<artifactId>tika-parsers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queryparser</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-analyzers-phonetic</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
Expand Down Expand Up @@ -113,6 +123,11 @@
<artifactId>byteman-bmunit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.byteman</groupId>
<artifactId>byteman-install</artifactId>
Expand Down

0 comments on commit 6e432d3

Please sign in to comment.