From a7c37dc421880547f71178e93dfc04dafeb8fd2e Mon Sep 17 00:00:00 2001 From: Osma Suominen Date: Fri, 3 Mar 2017 10:34:50 +0200 Subject: [PATCH 1/3] Upgrade to Lucene 5.5.4, drop all version fields, reimplement multilingual analyzer (JENA-1250) --- jena-parent/pom.xml | 2 +- .../java/examples/JenaSpatialExample1.java | 2 +- .../src/main/java/jena/spatialindexdump.java | 2 +- .../query/spatial/SpatialIndexLucene.java | 13 ++-- .../SpatialIndexLuceneAssembler.java | 3 +- .../jena/query/spatial/SpatialSearchUtil.java | 13 +--- .../src/main/java/jena/textindexdump.java | 2 +- .../jena/query/text/TextDatasetFactory.java | 7 +- .../jena/query/text/TextIndexLucene.java | 51 ++++++++----- .../text/TextIndexLuceneMultilingual.java | 75 ------------------- .../text/analyzer/ConfigurableAnalyzer.java | 24 +++--- .../analyzer/LowerCaseKeywordAnalyzer.java | 14 +--- .../text/analyzer/MultilingualAnalyzer.java | 54 +++++++++++++ .../apache/jena/query/text/analyzer/Util.java | 10 +-- .../ConfigurableAnalyzerAssembler.java | 3 +- .../assembler/LocalizedAnalyzerAssembler.java | 5 +- .../LowerCaseKeywordAnalyzerAssembler.java | 3 +- .../assembler/SimpleAnalyzerAssembler.java | 3 +- .../assembler/StandardAnalyzerAssembler.java | 7 +- .../assembler/TextIndexLuceneAssembler.java | 5 +- .../text/TestLuceneWithMultipleThreads.java | 3 +- .../jena/query/text/TextSearchUtil.java | 8 +- 22 files changed, 132 insertions(+), 177 deletions(-) delete mode 100644 jena-text/src/main/java/org/apache/jena/query/text/TextIndexLuceneMultilingual.java create mode 100644 jena-text/src/main/java/org/apache/jena/query/text/analyzer/MultilingualAnalyzer.java diff --git a/jena-parent/pom.xml b/jena-parent/pom.xml index 8af18b4dddd..e801e8334b5 100644 --- a/jena-parent/pom.xml +++ b/jena-parent/pom.xml @@ -72,7 +72,7 @@ ${ver.httpclient} 1.10 - 4.9.1 + 5.5.4 4.9.1 0.5 diff --git a/jena-spatial/src/main/java/examples/JenaSpatialExample1.java b/jena-spatial/src/main/java/examples/JenaSpatialExample1.java index b858b17806e..03f77e7ce44 100644 --- a/jena-spatial/src/main/java/examples/JenaSpatialExample1.java +++ b/jena-spatial/src/main/java/examples/JenaSpatialExample1.java @@ -140,7 +140,7 @@ private static Dataset joinDataset(Dataset baseDataset, File indexDir) throws IO // Lucene, index in File system. - Directory dir = FSDirectory.open(indexDir); + Directory dir = FSDirectory.open(indexDir.toPath()); // Join together into a dataset Dataset ds = SpatialDatasetFactory.createLucene(baseDataset, dir, entDef); diff --git a/jena-spatial/src/main/java/jena/spatialindexdump.java b/jena-spatial/src/main/java/jena/spatialindexdump.java index 904637cce6e..29a3d5df747 100644 --- a/jena-spatial/src/main/java/jena/spatialindexdump.java +++ b/jena-spatial/src/main/java/jena/spatialindexdump.java @@ -103,7 +103,7 @@ private static void dump(SpatialIndexLucene spatialIndex) { Analyzer analyzer = spatialIndex.getAnalyzer() ; IndexReader indexReader = DirectoryReader.open(directory) ; IndexSearcher indexSearcher = new IndexSearcher(indexReader); - QueryParser queryParser = new QueryParser(SpatialIndexLucene.VER, spatialIndex.getDocDef().getEntityField(), analyzer); + QueryParser queryParser = new QueryParser(spatialIndex.getDocDef().getEntityField(), analyzer); Query query = queryParser.parse("*:*"); ScoreDoc[] sDocs = indexSearcher.search(query, 1000).scoreDocs ; for ( ScoreDoc sd : sDocs ) { diff --git a/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialIndexLucene.java b/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialIndexLucene.java index e340cd6dd56..85a8bb42fbc 100644 --- a/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialIndexLucene.java +++ b/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialIndexLucene.java @@ -37,7 +37,6 @@ import org.apache.lucene.spatial.query.SpatialArgs ; import org.apache.lucene.spatial.query.SpatialOperation ; import org.apache.lucene.store.Directory ; -import org.apache.lucene.util.Version ; import org.slf4j.Logger ; import org.slf4j.LoggerFactory ; @@ -48,14 +47,13 @@ public class SpatialIndexLucene implements SpatialIndex { .getLogger(SpatialIndexLucene.class); private static int MAX_N = 10000; - public static final Version VER = Version.LUCENE_4_9; public static final FieldType ftIRI; static { ftIRI = new FieldType(); ftIRI.setTokenized(false); ftIRI.setStored(true); - ftIRI.setIndexed(true); + ftIRI.setIndexOptions(IndexOptions.DOCS); ftIRI.freeze(); } // public static final FieldType ftText = TextField.TYPE_NOT_STORED ; @@ -65,7 +63,7 @@ public class SpatialIndexLucene implements SpatialIndex { private final EntityDefinition docDef; private final Directory directory; private IndexWriter indexWriter; - private Analyzer analyzer = new StandardAnalyzer(VER); + private Analyzer analyzer = new StandardAnalyzer(); /** * The Lucene spatial {@link SpatialStrategy} encapsulates an approach to @@ -108,7 +106,7 @@ public Analyzer getAnalyzer() { @Override public void startIndexing() { try { - IndexWriterConfig wConfig = new IndexWriterConfig(VER, analyzer); + IndexWriterConfig wConfig = new IndexWriterConfig(analyzer); indexWriter = new IndexWriter(directory, wConfig); } catch (IOException e) { exception(e); @@ -193,9 +191,8 @@ public List query(Shape shape, int limit, SpatialOperation operation) { IndexSearcher indexSearcher = new IndexSearcher(indexReader); SpatialArgs args = new SpatialArgs(operation, shape); args.setDistErr(0.0); - Filter filter = strategy.makeFilter(args); - TopDocs docs = indexSearcher.search(new MatchAllDocsQuery(), filter, - limit); + Query query = strategy.makeQuery(args); + TopDocs docs = indexSearcher.search(query, limit); List results = new ArrayList<>(); diff --git a/jena-spatial/src/main/java/org/apache/jena/query/spatial/assembler/SpatialIndexLuceneAssembler.java b/jena-spatial/src/main/java/org/apache/jena/query/spatial/assembler/SpatialIndexLuceneAssembler.java index 5554e3da6d6..643b54e4c63 100644 --- a/jena-spatial/src/main/java/org/apache/jena/query/spatial/assembler/SpatialIndexLuceneAssembler.java +++ b/jena-spatial/src/main/java/org/apache/jena/query/spatial/assembler/SpatialIndexLuceneAssembler.java @@ -50,7 +50,6 @@ public class SpatialIndexLuceneAssembler extends AssemblerBase . */ - @SuppressWarnings("resource") @Override public SpatialIndex open(Assembler a, Resource root, Mode mode) { @@ -72,7 +71,7 @@ public SpatialIndex open(Assembler a, Resource root, Mode mode) Resource x = n.asResource() ; String path = IRILib.IRIToFilename(x.getURI()) ; File dir = new File(path) ; - directory = FSDirectory.open(dir) ; + directory = FSDirectory.open(dir.toPath()) ; } Resource r = GraphUtils.getResourceValue(root, pDefinition) ; diff --git a/jena-spatial/src/test/java/org/apache/jena/query/spatial/SpatialSearchUtil.java b/jena-spatial/src/test/java/org/apache/jena/query/spatial/SpatialSearchUtil.java index a1b5f08d9db..8d0453ad494 100644 --- a/jena-spatial/src/test/java/org/apache/jena/query/spatial/SpatialSearchUtil.java +++ b/jena-spatial/src/test/java/org/apache/jena/query/spatial/SpatialSearchUtil.java @@ -31,13 +31,9 @@ import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.store.Directory; import org.apache.lucene.store.FSDirectory; -import org.apache.lucene.util.Version; public class SpatialSearchUtil { - - private static Version VER = SpatialIndexLucene.VER ; - private static final Analyzer analyzer = new StandardAnalyzer(VER); - + private static final Analyzer analyzer = new StandardAnalyzer(); private static final String LUCENE_INDEX_PATH = "target/test/LuceneSpatialIndex"; private static final File LUCENE_Index_DIR = new File(LUCENE_INDEX_PATH); @@ -63,9 +59,8 @@ public static void emptyAndDeleteDirectory(File dir) { public static void createEmptyIndex(File indexDir) { try { - Directory directory = FSDirectory.open(indexDir) ; - IndexWriterConfig wConfig = new IndexWriterConfig(VER, analyzer) ; - @SuppressWarnings("resource") + Directory directory = FSDirectory.open(indexDir.toPath()) ; + IndexWriterConfig wConfig = new IndexWriterConfig(analyzer) ; IndexWriter indexWriter = new IndexWriter(directory, wConfig) ; indexWriter.close() ; // force creation of the index files } catch (IOException ex) { @@ -126,7 +121,7 @@ private static Dataset joinDataset(Dataset baseDataset, File indexDir) throws IO EntityDefinition entDef = new EntityDefinition("uri", "geo"); // Lucene, index in File system. - Directory dir = FSDirectory.open(indexDir); + Directory dir = FSDirectory.open(indexDir.toPath()); // Join together into a dataset Dataset ds = SpatialDatasetFactory.createLucene(baseDataset, dir, entDef); diff --git a/jena-text/src/main/java/jena/textindexdump.java b/jena-text/src/main/java/jena/textindexdump.java index 0226094425f..08f6cfb5087 100644 --- a/jena-text/src/main/java/jena/textindexdump.java +++ b/jena-text/src/main/java/jena/textindexdump.java @@ -101,7 +101,7 @@ private static void dump(TextIndexLucene textIndex) { Analyzer analyzer = textIndex.getQueryAnalyzer() ; IndexReader indexReader = DirectoryReader.open(directory) ; IndexSearcher indexSearcher = new IndexSearcher(indexReader); - QueryParser queryParser = new QueryParser(TextIndexLucene.VER, textIndex.getDocDef().getPrimaryField(), analyzer); + QueryParser queryParser = new QueryParser(textIndex.getDocDef().getPrimaryField(), analyzer); Query query = queryParser.parse("*:*"); ScoreDoc[] sDocs = indexSearcher.search(query, 1000).scoreDocs ; for ( ScoreDoc sd : sDocs ) { diff --git a/jena-text/src/main/java/org/apache/jena/query/text/TextDatasetFactory.java b/jena-text/src/main/java/org/apache/jena/query/text/TextDatasetFactory.java index 544082beda6..043c4823b1f 100644 --- a/jena-text/src/main/java/org/apache/jena/query/text/TextDatasetFactory.java +++ b/jena-text/src/main/java/org/apache/jena/query/text/TextDatasetFactory.java @@ -107,12 +107,7 @@ public static TextIndex createLuceneIndex(Directory directory, EntityDefinition */ public static TextIndex createLuceneIndex(Directory directory, TextIndexConfig config) { - TextIndex index; - if (config.isMultilingualSupport()) - index = new TextIndexLuceneMultilingual(directory, config) ; - else - index = new TextIndexLucene(directory, config) ; - return index ; + return new TextIndexLucene(directory, config) ; } /** diff --git a/jena-text/src/main/java/org/apache/jena/query/text/TextIndexLucene.java b/jena-text/src/main/java/org/apache/jena/query/text/TextIndexLucene.java index e6ef89fcc21..b40ba03f31c 100644 --- a/jena-text/src/main/java/org/apache/jena/query/text/TextIndexLucene.java +++ b/jena-text/src/main/java/org/apache/jena/query/text/TextIndexLucene.java @@ -27,6 +27,7 @@ import org.apache.jena.datatypes.xsd.XSDDatatype ; import org.apache.jena.graph.Node ; import org.apache.jena.graph.NodeFactory ; +import org.apache.jena.query.text.analyzer.MultilingualAnalyzer; import org.apache.jena.sparql.util.NodeFactoryExtra ; import org.apache.lucene.analysis.Analyzer ; import org.apache.lucene.analysis.core.KeywordAnalyzer ; @@ -43,7 +44,6 @@ import org.apache.lucene.search.Query ; import org.apache.lucene.search.ScoreDoc ; import org.apache.lucene.store.Directory ; -import org.apache.lucene.util.Version ; import org.slf4j.Logger ; import org.slf4j.LoggerFactory ; @@ -51,7 +51,6 @@ public class TextIndexLucene implements TextIndex { private static Logger log = LoggerFactory.getLogger(TextIndexLucene.class) ; private static int MAX_N = 10000 ; - public static final Version VER = Version.LUCENE_4_9 ; // prefix for storing datatype URIs in the index, to distinguish them from language tags private static final String DATATYPE_PREFIX = "^^"; @@ -60,7 +59,7 @@ public class TextIndexLucene implements TextIndex { ftIRI = new FieldType() ; ftIRI.setTokenized(false) ; ftIRI.setStored(true) ; - ftIRI.setIndexed(true) ; + ftIRI.setIndexOptions(IndexOptions.DOCS); ftIRI.freeze() ; } public static final FieldType ftString = StringField.TYPE_NOT_STORED ; @@ -71,6 +70,7 @@ public class TextIndexLucene implements TextIndex { private final Analyzer queryAnalyzer ; private final String queryParserType ; private final FieldType ftText ; + private final boolean isMultilingual ; // The IndexWriter can't be final because we may have to recreate it if rollback() is called. // However, it needs to be volatile in case the next write transaction is on a different thread, @@ -88,8 +88,14 @@ public TextIndexLucene(Directory directory, TextIndexConfig config) { this.directory = directory ; this.docDef = config.getEntDef() ; + this.isMultilingual = config.isMultilingualSupport(); + if (this.isMultilingual && config.getEntDef().getLangField() == null) { + //multilingual index cannot work without lang field + docDef.setLangField("lang"); + } + // create the analyzer as a wrapper that uses KeywordAnalyzer for - // entity and graph fields and StandardAnalyzer for all other + // entity and graph fields and the configured analyzer(s) for all other Map analyzerPerField = new HashMap<>() ; analyzerPerField.put(docDef.getEntityField(), new KeywordAnalyzer()) ; if ( docDef.getGraphField() != null ) @@ -104,8 +110,10 @@ public TextIndexLucene(Directory directory, TextIndexConfig config) { } } - this.analyzer = new PerFieldAnalyzerWrapper( - (null != config.getAnalyzer()) ? config.getAnalyzer() : new StandardAnalyzer(VER), analyzerPerField) ; + Analyzer defaultAnalyzer = (null != config.getAnalyzer()) ? config.getAnalyzer() : new StandardAnalyzer(); + if (this.isMultilingual) + defaultAnalyzer = new MultilingualAnalyzer(defaultAnalyzer); + this.analyzer = new PerFieldAnalyzerWrapper(defaultAnalyzer, analyzerPerField) ; this.queryAnalyzer = (null != config.getQueryAnalyzer()) ? config.getQueryAnalyzer() : this.analyzer ; this.queryParserType = config.getQueryParser() ; this.ftText = config.isValueStored() ? TextField.TYPE_STORED : TextField.TYPE_NOT_STORED ; @@ -116,7 +124,7 @@ public TextIndexLucene(Directory directory, TextIndexConfig config) { } private void openIndexWriter() { - IndexWriterConfig wConfig = new IndexWriterConfig(VER, analyzer) ; + IndexWriterConfig wConfig = new IndexWriterConfig(analyzer) ; try { indexWriter = new IndexWriter(directory, wConfig) ; @@ -264,6 +272,10 @@ protected Document doc(Entity entity) { RDFDatatype datatype = entity.getDatatype(); if (lang != null && !"".equals(lang)) { doc.add(new Field(langField, lang, StringField.TYPE_STORED)); + if (this.isMultilingual) { + // add a field that uses a language-specific analyzer via MultilingualAnalyzer + doc.add(new Field(e.getKey() + "_" + lang, (String) e.getValue(), ftText)); + } } else if (datatype != null && !datatype.equals(XSDDatatype.XSDstring)) { // for non-string and non-langString datatypes, store the datatype in langField doc.add(new Field(langField, DATATYPE_PREFIX + datatype.getURI(), StringField.TYPE_STORED)); @@ -296,32 +308,37 @@ public Map get(String uri) { private QueryParser getQueryParser(Analyzer analyzer) { switch(queryParserType) { case "QueryParser": - return new QueryParser(VER, docDef.getPrimaryField(), analyzer) ; + return new QueryParser(docDef.getPrimaryField(), analyzer) ; case "AnalyzingQueryParser": - return new AnalyzingQueryParser(VER, docDef.getPrimaryField(), analyzer) ; + return new AnalyzingQueryParser(docDef.getPrimaryField(), analyzer) ; case "ComplexPhraseQueryParser": - return new ComplexPhraseQueryParser(VER, docDef.getPrimaryField(), analyzer); + return new ComplexPhraseQueryParser(docDef.getPrimaryField(), analyzer); default: log.warn("Unknown query parser type '" + queryParserType + "'. Defaulting to standard QueryParser") ; - return new QueryParser(VER, docDef.getPrimaryField(), analyzer) ; + return new QueryParser(docDef.getPrimaryField(), analyzer) ; } } private Query parseQuery(String queryString, Analyzer analyzer) throws ParseException { + if (this.isMultilingual) { + if (queryString.contains(getDocDef().getLangField() + ":")) { + String lang = queryString.substring(queryString.lastIndexOf(":") + 1); + if (!"*".equals(lang)) { + // splice the language into the field name + queryString = queryString.replaceFirst(":", "_" + lang + ":"); + } + } + } QueryParser queryParser = getQueryParser(analyzer) ; queryParser.setAllowLeadingWildcard(true) ; Query query = queryParser.parse(queryString) ; return query ; } - protected Query preParseQuery(String queryString, Analyzer analyzer) throws ParseException { - return parseQuery(queryString, analyzer); - } - private List> get$(IndexReader indexReader, String uri) throws ParseException, IOException { String escaped = QueryParserBase.escape(uri) ; String qs = docDef.getEntityField() + ":" + escaped ; - Query query = preParseQuery(qs, queryAnalyzer) ; + Query query = parseQuery(qs, queryAnalyzer) ; IndexSearcher indexSearcher = new IndexSearcher(indexReader) ; ScoreDoc[] sDocs = indexSearcher.search(query, 1).scoreDocs ; List> records = new ArrayList<>() ; @@ -369,7 +386,7 @@ public List query(Node property, String qs, int limit) { private List query$(IndexReader indexReader, Node property, String qs, int limit) throws ParseException, IOException { IndexSearcher indexSearcher = new IndexSearcher(indexReader) ; - Query query = preParseQuery(qs, queryAnalyzer) ; + Query query = parseQuery(qs, queryAnalyzer) ; if ( limit <= 0 ) limit = MAX_N ; ScoreDoc[] sDocs = indexSearcher.search(query, limit).scoreDocs ; diff --git a/jena-text/src/main/java/org/apache/jena/query/text/TextIndexLuceneMultilingual.java b/jena-text/src/main/java/org/apache/jena/query/text/TextIndexLuceneMultilingual.java deleted file mode 100644 index ec7a8bb608b..00000000000 --- a/jena-text/src/main/java/org/apache/jena/query/text/TextIndexLuceneMultilingual.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.jena.query.text; - -import org.apache.jena.query.text.analyzer.Util; -import org.apache.lucene.analysis.Analyzer; -import org.apache.lucene.document.Document; -import org.apache.lucene.index.Term; -import org.apache.lucene.queryparser.classic.ParseException; -import org.apache.lucene.search.Query; -import org.apache.lucene.store.Directory; - -import java.io.IOException; - -public class TextIndexLuceneMultilingual extends TextIndexLucene { - - /** - * Constructs a new TextIndexLuceneMultilingual. - * - * @param directory The Lucene Directory for the index - * @param config The config definition for the index instantiation. - */ - public TextIndexLuceneMultilingual(Directory directory, TextIndexConfig config) { - super(directory, config) ; - - //multilingual index cannot work without lang field - if (config.getEntDef().getLangField() == null) - config.getEntDef().setLangField("lang"); - } - - @Override - protected void updateDocument(Entity entity) throws IOException { - Document doc = doc(entity); - Term term = new Term(getDocDef().getEntityField(), entity.getId()); - Analyzer analyzer = Util.getLocalizedAnalyzer(entity.getLanguage()); - if (analyzer == null) - analyzer = getAnalyzer(); - getIndexWriter().updateDocument(term, doc, analyzer) ; - } - - @Override - protected void addDocument(Entity entity) throws IOException { - Document doc = doc(entity) ; - Analyzer analyzer = Util.getLocalizedAnalyzer(entity.getLanguage()); - if (analyzer == null) - analyzer = getAnalyzer(); - getIndexWriter().addDocument(doc, analyzer) ; - } - - @Override - protected Query preParseQuery(String queryString, Analyzer analyzer) throws ParseException { - if (queryString.contains(getDocDef().getLangField() + ":")) { - String lang = queryString.substring(queryString.lastIndexOf(":") + 1); - if (!"*".equals(lang)) - analyzer = Util.getLocalizedAnalyzer(lang); - } - return super.preParseQuery(queryString, analyzer); - } -} diff --git a/jena-text/src/main/java/org/apache/jena/query/text/analyzer/ConfigurableAnalyzer.java b/jena-text/src/main/java/org/apache/jena/query/text/analyzer/ConfigurableAnalyzer.java index ada3361360c..8960ddbeaa3 100644 --- a/jena-text/src/main/java/org/apache/jena/query/text/analyzer/ConfigurableAnalyzer.java +++ b/jena-text/src/main/java/org/apache/jena/query/text/analyzer/ConfigurableAnalyzer.java @@ -18,7 +18,6 @@ package org.apache.jena.query.text.analyzer ; -import java.io.Reader ; import java.util.List ; import org.apache.jena.query.text.TextIndexException; @@ -33,7 +32,6 @@ import org.apache.lucene.analysis.miscellaneous.ASCIIFoldingFilter; import org.apache.lucene.analysis.standard.StandardFilter; import org.apache.lucene.analysis.standard.StandardTokenizer; -import org.apache.lucene.util.Version ; /** @@ -42,20 +40,19 @@ */ public class ConfigurableAnalyzer extends Analyzer { - private final Version version; private final String tokenizer; private final List filters; - private Tokenizer getTokenizer(String tokenizerName, Reader reader) { + private Tokenizer getTokenizer(String tokenizerName) { switch(tokenizerName) { case "KeywordTokenizer": - return new KeywordTokenizer(reader); + return new KeywordTokenizer(); case "LetterTokenizer": - return new LetterTokenizer(version, reader); + return new LetterTokenizer(); case "StandardTokenizer": - return new StandardTokenizer(version, reader); + return new StandardTokenizer(); case "WhitespaceTokenizer": - return new WhitespaceTokenizer(version, reader); + return new WhitespaceTokenizer(); default: throw new TextIndexException("Unknown tokenizer : " + tokenizerName); } @@ -66,23 +63,22 @@ private TokenFilter getTokenFilter(String filterName, TokenStream source) { case "ASCIIFoldingFilter": return new ASCIIFoldingFilter(source); case "LowerCaseFilter": - return new LowerCaseFilter(version, source); + return new LowerCaseFilter(source); case "StandardFilter": - return new StandardFilter(version, source); + return new StandardFilter(source); default: throw new TextIndexException("Unknown filter : " + filterName); } } - public ConfigurableAnalyzer(Version ver, String tokenizer, List filters) { - this.version = ver; + public ConfigurableAnalyzer(String tokenizer, List filters) { this.tokenizer = tokenizer; this.filters = filters; } @Override - protected TokenStreamComponents createComponents(String fieldName, Reader reader) { - Tokenizer source = getTokenizer(this.tokenizer, reader); + protected TokenStreamComponents createComponents(String fieldName) { + Tokenizer source = getTokenizer(this.tokenizer); TokenStream stream = source; for (String filter : this.filters) { stream = getTokenFilter(filter, stream); diff --git a/jena-text/src/main/java/org/apache/jena/query/text/analyzer/LowerCaseKeywordAnalyzer.java b/jena-text/src/main/java/org/apache/jena/query/text/analyzer/LowerCaseKeywordAnalyzer.java index 2b168b41a48..071569bac3a 100644 --- a/jena-text/src/main/java/org/apache/jena/query/text/analyzer/LowerCaseKeywordAnalyzer.java +++ b/jena-text/src/main/java/org/apache/jena/query/text/analyzer/LowerCaseKeywordAnalyzer.java @@ -18,12 +18,9 @@ package org.apache.jena.query.text.analyzer ; -import java.io.Reader ; - import org.apache.lucene.analysis.Analyzer ; import org.apache.lucene.analysis.core.KeywordTokenizer ; import org.apache.lucene.analysis.core.LowerCaseFilter ; -import org.apache.lucene.util.Version ; /** @@ -33,16 +30,11 @@ */ public class LowerCaseKeywordAnalyzer extends Analyzer { - private Version version; - - public LowerCaseKeywordAnalyzer(Version ver) { - this.version = ver; - } @Override - protected TokenStreamComponents createComponents(String fieldName, Reader reader) { - KeywordTokenizer source = new KeywordTokenizer(reader); - LowerCaseFilter filter = new LowerCaseFilter(version, source); + protected TokenStreamComponents createComponents(String fieldName) { + KeywordTokenizer source = new KeywordTokenizer(); + LowerCaseFilter filter = new LowerCaseFilter(source); return new TokenStreamComponents(source, filter); } diff --git a/jena-text/src/main/java/org/apache/jena/query/text/analyzer/MultilingualAnalyzer.java b/jena-text/src/main/java/org/apache/jena/query/text/analyzer/MultilingualAnalyzer.java new file mode 100644 index 00000000000..1ba21d10eab --- /dev/null +++ b/jena-text/src/main/java/org/apache/jena/query/text/analyzer/MultilingualAnalyzer.java @@ -0,0 +1,54 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jena.query.text.analyzer ; + +import org.apache.lucene.analysis.Analyzer ; +import org.apache.lucene.analysis.DelegatingAnalyzerWrapper; + + +/** + * Lucene Analyzer implementation that delegates to a language-specific + * Analyzer based on a field name suffix: e.g. field="label_en" will use + * an EnglishAnalyzer. + */ + +public class MultilingualAnalyzer extends DelegatingAnalyzerWrapper { + private Analyzer defaultAnalyzer; + + public MultilingualAnalyzer(Analyzer defaultAnalyzer) { + super(PER_FIELD_REUSE_STRATEGY); + this.defaultAnalyzer = defaultAnalyzer; + } + + @Override + protected Analyzer getWrappedAnalyzer(String fieldName) { + int idx = fieldName.lastIndexOf("_"); + if (idx == -1) { // not language-specific, e.g. "label" + return defaultAnalyzer; + } + String lang = fieldName.substring(idx+1); + Analyzer analyzer = Util.getLocalizedAnalyzer(lang); + return (analyzer != null ? analyzer : defaultAnalyzer); + } + + @Override + public String toString() { + return "MultilingualAnalyzer(default=" + defaultAnalyzer + ")"; + } +} diff --git a/jena-text/src/main/java/org/apache/jena/query/text/analyzer/Util.java b/jena-text/src/main/java/org/apache/jena/query/text/analyzer/Util.java index c8e34906207..fb2582a5b08 100644 --- a/jena-text/src/main/java/org/apache/jena/query/text/analyzer/Util.java +++ b/jena-text/src/main/java/org/apache/jena/query/text/analyzer/Util.java @@ -18,9 +18,7 @@ package org.apache.jena.query.text.analyzer; -import org.apache.jena.query.text.TextIndexLucene; import org.apache.lucene.analysis.Analyzer; -import org.apache.lucene.util.Version; import java.lang.reflect.Constructor; import java.util.Hashtable; @@ -34,10 +32,6 @@ public class Util { } public static Analyzer getLocalizedAnalyzer(String lang) { - return getLocalizedAnalyzer(lang, TextIndexLucene.VER); - } - - public static Analyzer getLocalizedAnalyzer(String lang, Version ver) { if (lang == null) return null; @@ -48,8 +42,8 @@ public static Analyzer getLocalizedAnalyzer(String lang, Version ver) { Class className = analyzersClasses.get(lang); if (className == null) return null; - Constructor constructor = className.getConstructor(Version.class); - Analyzer analyzer = (Analyzer)constructor.newInstance(ver); + Constructor constructor = className.getConstructor(); + Analyzer analyzer = (Analyzer)constructor.newInstance(); cache.put(lang, analyzer); return analyzer; } catch (Exception e) { diff --git a/jena-text/src/main/java/org/apache/jena/query/text/assembler/ConfigurableAnalyzerAssembler.java b/jena-text/src/main/java/org/apache/jena/query/text/assembler/ConfigurableAnalyzerAssembler.java index d336ed80727..5ec96eb7053 100644 --- a/jena-text/src/main/java/org/apache/jena/query/text/assembler/ConfigurableAnalyzerAssembler.java +++ b/jena-text/src/main/java/org/apache/jena/query/text/assembler/ConfigurableAnalyzerAssembler.java @@ -25,7 +25,6 @@ import org.apache.jena.assembler.Mode; import org.apache.jena.assembler.assemblers.AssemblerBase; import org.apache.jena.query.text.TextIndexException; -import org.apache.jena.query.text.TextIndexLucene; import org.apache.jena.query.text.analyzer.ConfigurableAnalyzer; import org.apache.jena.rdf.model.RDFNode; import org.apache.jena.rdf.model.Resource; @@ -64,7 +63,7 @@ public Analyzer open(Assembler a, Resource root, Mode mode) { } else { filters = new ArrayList<>(); } - return new ConfigurableAnalyzer(TextIndexLucene.VER, tokenizer, filters); + return new ConfigurableAnalyzer(tokenizer, filters); } else { throw new TextIndexException("text:tokenizer setting is required by ConfigurableAnalyzer"); } diff --git a/jena-text/src/main/java/org/apache/jena/query/text/assembler/LocalizedAnalyzerAssembler.java b/jena-text/src/main/java/org/apache/jena/query/text/assembler/LocalizedAnalyzerAssembler.java index b9d83dec6e9..f26adc44fc9 100644 --- a/jena-text/src/main/java/org/apache/jena/query/text/assembler/LocalizedAnalyzerAssembler.java +++ b/jena-text/src/main/java/org/apache/jena/query/text/assembler/LocalizedAnalyzerAssembler.java @@ -22,7 +22,6 @@ import org.apache.jena.assembler.Mode; import org.apache.jena.assembler.assemblers.AssemblerBase; import org.apache.jena.query.text.TextIndexException; -import org.apache.jena.query.text.TextIndexLucene; import org.apache.jena.query.text.analyzer.Util; import org.apache.jena.rdf.model.RDFNode; import org.apache.jena.rdf.model.Resource; @@ -52,9 +51,9 @@ public Analyzer open(Assembler a, Resource root, Mode mode) { throw new TextIndexException("text:language property must be a string : " + node); } String lang = node.toString(); - return Util.getLocalizedAnalyzer(lang, TextIndexLucene.VER); + return Util.getLocalizedAnalyzer(lang); } else { - return new StandardAnalyzer(TextIndexLucene.VER); + return new StandardAnalyzer(); } } } diff --git a/jena-text/src/main/java/org/apache/jena/query/text/assembler/LowerCaseKeywordAnalyzerAssembler.java b/jena-text/src/main/java/org/apache/jena/query/text/assembler/LowerCaseKeywordAnalyzerAssembler.java index be64d521048..9ad67f4cf82 100644 --- a/jena-text/src/main/java/org/apache/jena/query/text/assembler/LowerCaseKeywordAnalyzerAssembler.java +++ b/jena-text/src/main/java/org/apache/jena/query/text/assembler/LowerCaseKeywordAnalyzerAssembler.java @@ -21,7 +21,6 @@ import org.apache.jena.assembler.Assembler ; import org.apache.jena.assembler.Mode ; import org.apache.jena.assembler.assemblers.AssemblerBase ; -import org.apache.jena.query.text.TextIndexLucene; import org.apache.jena.query.text.analyzer.LowerCaseKeywordAnalyzer; import org.apache.jena.rdf.model.Resource ; import org.apache.lucene.analysis.Analyzer; @@ -42,6 +41,6 @@ public class LowerCaseKeywordAnalyzerAssembler extends AssemblerBase { @Override public Analyzer open(Assembler a, Resource root, Mode mode) { - return new LowerCaseKeywordAnalyzer(TextIndexLucene.VER); + return new LowerCaseKeywordAnalyzer(); } } diff --git a/jena-text/src/main/java/org/apache/jena/query/text/assembler/SimpleAnalyzerAssembler.java b/jena-text/src/main/java/org/apache/jena/query/text/assembler/SimpleAnalyzerAssembler.java index 39b4b4a73d3..d0f6fe725b6 100644 --- a/jena-text/src/main/java/org/apache/jena/query/text/assembler/SimpleAnalyzerAssembler.java +++ b/jena-text/src/main/java/org/apache/jena/query/text/assembler/SimpleAnalyzerAssembler.java @@ -21,7 +21,6 @@ import org.apache.jena.assembler.Assembler ; import org.apache.jena.assembler.Mode ; import org.apache.jena.assembler.assemblers.AssemblerBase ; -import org.apache.jena.query.text.TextIndexLucene; import org.apache.jena.rdf.model.Resource ; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.core.SimpleAnalyzer; @@ -43,6 +42,6 @@ public class SimpleAnalyzerAssembler extends AssemblerBase { @Override public Analyzer open(Assembler a, Resource root, Mode mode) { - return new SimpleAnalyzer(TextIndexLucene.VER); + return new SimpleAnalyzer(); } } diff --git a/jena-text/src/main/java/org/apache/jena/query/text/assembler/StandardAnalyzerAssembler.java b/jena-text/src/main/java/org/apache/jena/query/text/assembler/StandardAnalyzerAssembler.java index bfe1db52fdc..e221d19cd40 100644 --- a/jena-text/src/main/java/org/apache/jena/query/text/assembler/StandardAnalyzerAssembler.java +++ b/jena-text/src/main/java/org/apache/jena/query/text/assembler/StandardAnalyzerAssembler.java @@ -25,7 +25,6 @@ import org.apache.jena.assembler.Mode ; import org.apache.jena.assembler.assemblers.AssemblerBase ; import org.apache.jena.query.text.TextIndexException; -import org.apache.jena.query.text.TextIndexLucene; import org.apache.jena.rdf.model.Literal ; import org.apache.jena.rdf.model.RDFNode ; import org.apache.jena.rdf.model.Resource ; @@ -56,7 +55,7 @@ public Analyzer open(Assembler a, Resource root, Mode mode) { if (root.hasProperty(TextVocab.pStopWords)) { return analyzerWithStopWords(root); } else { - return new StandardAnalyzer(TextIndexLucene.VER); + return new StandardAnalyzer(); } } @@ -66,11 +65,11 @@ private Analyzer analyzerWithStopWords(Resource root) { throw new TextIndexException("text:stopWords property takes a list as a value : " + node); } CharArraySet stopWords = toCharArraySet((Resource) node); - return new StandardAnalyzer(TextIndexLucene.VER, stopWords); + return new StandardAnalyzer(stopWords); } private CharArraySet toCharArraySet(Resource list) { - return new CharArraySet(TextIndexLucene.VER, toList(list), false); + return new CharArraySet(toList(list), false); } private List toList(Resource list) { diff --git a/jena-text/src/main/java/org/apache/jena/query/text/assembler/TextIndexLuceneAssembler.java b/jena-text/src/main/java/org/apache/jena/query/text/assembler/TextIndexLuceneAssembler.java index 1af7e9d19cb..a4f2949210a 100644 --- a/jena-text/src/main/java/org/apache/jena/query/text/assembler/TextIndexLuceneAssembler.java +++ b/jena-text/src/main/java/org/apache/jena/query/text/assembler/TextIndexLuceneAssembler.java @@ -48,7 +48,6 @@ public class TextIndexLuceneAssembler extends AssemblerBase { . */ - @SuppressWarnings("resource") @Override public TextIndex open(Assembler a, Resource root, Mode mode) { try { @@ -64,13 +63,13 @@ public TextIndex open(Assembler a, Resource root, Mode mode) { directory = new RAMDirectory() ; } else { File dir = new File(literalValue) ; - directory = FSDirectory.open(dir) ; + directory = FSDirectory.open(dir.toPath()) ; } } else { Resource x = n.asResource() ; String path = IRILib.IRIToFilename(x.getURI()) ; File dir = new File(path) ; - directory = FSDirectory.open(dir) ; + directory = FSDirectory.open(dir.toPath()) ; } Analyzer analyzer = null; diff --git a/jena-text/src/test/java/org/apache/jena/query/text/TestLuceneWithMultipleThreads.java b/jena-text/src/test/java/org/apache/jena/query/text/TestLuceneWithMultipleThreads.java index 2b970645e78..223857c9b8f 100644 --- a/jena-text/src/test/java/org/apache/jena/query/text/TestLuceneWithMultipleThreads.java +++ b/jena-text/src/test/java/org/apache/jena/query/text/TestLuceneWithMultipleThreads.java @@ -35,7 +35,6 @@ import org.apache.jena.vocabulary.RDFS ; import org.apache.lucene.analysis.standard.StandardAnalyzer ; import org.apache.lucene.store.RAMDirectory ; -import org.apache.lucene.util.Version ; import org.junit.Test ; /** @@ -49,7 +48,7 @@ public class TestLuceneWithMultipleThreads entDef = new EntityDefinition("uri", "label"); entDef.setGraphField("graph"); entDef.setPrimaryPredicate(RDFS.label); - StandardAnalyzer analyzer = new StandardAnalyzer(Version.LUCENE_4_9); + StandardAnalyzer analyzer = new StandardAnalyzer(); entDef.setAnalyzer("label", analyzer); } diff --git a/jena-text/src/test/java/org/apache/jena/query/text/TextSearchUtil.java b/jena-text/src/test/java/org/apache/jena/query/text/TextSearchUtil.java index 8f132f7a560..c5bb0a4f79c 100644 --- a/jena-text/src/test/java/org/apache/jena/query/text/TextSearchUtil.java +++ b/jena-text/src/test/java/org/apache/jena/query/text/TextSearchUtil.java @@ -28,11 +28,9 @@ import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.store.Directory; import org.apache.lucene.store.FSDirectory; -import org.apache.lucene.util.Version; public class TextSearchUtil { - private static Version VER = TextIndexLucene.VER ; - private static final Analyzer analyzer = new StandardAnalyzer(VER); + private static final Analyzer analyzer = new StandardAnalyzer(); public static void emptyAndDeleteDirectory(File dir) { File[] contents = dir.listFiles() ; @@ -50,8 +48,8 @@ public static void emptyAndDeleteDirectory(File dir) { public static void createEmptyIndex(File indexDir) { try { - Directory directory = FSDirectory.open(indexDir) ; - IndexWriterConfig wConfig = new IndexWriterConfig(VER, analyzer) ; + Directory directory = FSDirectory.open(indexDir.toPath()) ; + IndexWriterConfig wConfig = new IndexWriterConfig(analyzer) ; // force creation of the index files try(IndexWriter indexWriter = new IndexWriter(directory, wConfig)) { } From ac06febffd297cb68dfbb11c620601604f657839 Mon Sep 17 00:00:00 2001 From: Osma Suominen Date: Fri, 3 Mar 2017 11:33:08 +0200 Subject: [PATCH 2/3] Upgrade to Lucene 6.4.1 and spatial4j 0.6. Add normalize method to ConfigurableAnalyzer for Lucene 6.2+ compatibility. (JENA-1250) --- jena-parent/pom.xml | 12 +++++++++--- jena-spatial/pom.xml | 7 ++++++- .../jena/query/spatial/DistanceUnitsUtils.java | 2 +- .../apache/jena/query/spatial/EntityDefinition.java | 2 +- .../org/apache/jena/query/spatial/SpatialIndex.java | 2 +- .../jena/query/spatial/SpatialIndexContext.java | 2 +- .../jena/query/spatial/SpatialIndexLucene.java | 2 +- .../apache/jena/query/spatial/SpatialIndexSolr.java | 2 +- .../org/apache/jena/query/spatial/SpatialQuery.java | 4 ++-- .../spatial/assembler/EntityDefinitionAssembler.java | 2 +- .../jena/query/spatial/pfunction/SpatialMatch.java | 2 +- .../spatial/AbstractTestIndexingSpatialData.java | 2 +- .../assembler/TestEntityDefinitionAssembler.java | 4 ++-- .../query/text/analyzer/ConfigurableAnalyzer.java | 9 +++++++++ .../text/assembler/StandardAnalyzerAssembler.java | 2 +- 15 files changed, 38 insertions(+), 18 deletions(-) diff --git a/jena-parent/pom.xml b/jena-parent/pom.xml index e801e8334b5..5e0c8a9fb51 100644 --- a/jena-parent/pom.xml +++ b/jena-parent/pom.xml @@ -72,9 +72,9 @@ ${ver.httpclient} 1.10 - 5.5.4 + 6.4.1 4.9.1 - 0.5 + 0.6 1.9.5 1.7.0 @@ -286,7 +286,13 @@ - com.spatial4j + org.apache.lucene + lucene-spatial-extras + ${ver.lucene} + + + + org.locationtech.spatial4j spatial4j ${ver.spatial4j} diff --git a/jena-spatial/pom.xml b/jena-spatial/pom.xml index 59aad5e3336..fc8f9487d96 100644 --- a/jena-spatial/pom.xml +++ b/jena-spatial/pom.xml @@ -73,6 +73,11 @@ lucene-spatial + + org.apache.lucene + lucene-spatial-extras + + org.apache.lucene lucene-analyzers-common @@ -84,7 +89,7 @@ - com.spatial4j + org.locationtech.spatial4j spatial4j diff --git a/jena-spatial/src/main/java/org/apache/jena/query/spatial/DistanceUnitsUtils.java b/jena-spatial/src/main/java/org/apache/jena/query/spatial/DistanceUnitsUtils.java index 2d1ab58fe0b..e0a4c25de84 100644 --- a/jena-spatial/src/main/java/org/apache/jena/query/spatial/DistanceUnitsUtils.java +++ b/jena-spatial/src/main/java/org/apache/jena/query/spatial/DistanceUnitsUtils.java @@ -21,7 +21,7 @@ import java.util.ArrayList; import java.util.List; -import com.spatial4j.core.distance.DistanceUtils; +import org.locationtech.spatial4j.distance.DistanceUtils; public class DistanceUnitsUtils { diff --git a/jena-spatial/src/main/java/org/apache/jena/query/spatial/EntityDefinition.java b/jena-spatial/src/main/java/org/apache/jena/query/spatial/EntityDefinition.java index 58f100b5525..975161b266b 100644 --- a/jena-spatial/src/main/java/org/apache/jena/query/spatial/EntityDefinition.java +++ b/jena-spatial/src/main/java/org/apache/jena/query/spatial/EntityDefinition.java @@ -28,7 +28,7 @@ import org.apache.jena.rdf.model.Resource ; import org.apache.jena.rdf.model.ResourceFactory ; -import com.spatial4j.core.context.SpatialContextFactory; +import org.locationtech.spatial4j.context.SpatialContextFactory; /** * Definition of a "document" diff --git a/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialIndex.java b/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialIndex.java index 9c9bf6f825d..ea7d2403877 100644 --- a/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialIndex.java +++ b/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialIndex.java @@ -24,7 +24,7 @@ import org.apache.jena.graph.Node ; import org.apache.lucene.spatial.query.SpatialOperation; -import com.spatial4j.core.shape.Shape; +import org.locationtech.spatial4j.shape.Shape; /** SpatialIndex abstraction */ public interface SpatialIndex extends Closeable //, Transactional diff --git a/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialIndexContext.java b/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialIndexContext.java index 2fc795300e5..fe556569416 100644 --- a/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialIndexContext.java +++ b/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialIndexContext.java @@ -27,7 +27,7 @@ import org.apache.jena.atlas.logging.Log ; import org.apache.jena.graph.Node ; -import com.spatial4j.core.shape.Shape; +import org.locationtech.spatial4j.shape.Shape; public class SpatialIndexContext { diff --git a/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialIndexLucene.java b/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialIndexLucene.java index 85a8bb42fbc..440df4dc993 100644 --- a/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialIndexLucene.java +++ b/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialIndexLucene.java @@ -40,7 +40,7 @@ import org.slf4j.Logger ; import org.slf4j.LoggerFactory ; -import com.spatial4j.core.shape.Shape ; +import org.locationtech.spatial4j.shape.Shape ; public class SpatialIndexLucene implements SpatialIndex { private static Logger log = LoggerFactory diff --git a/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialIndexSolr.java b/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialIndexSolr.java index 507e6eeb039..49a6fb8e894 100644 --- a/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialIndexSolr.java +++ b/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialIndexSolr.java @@ -38,7 +38,7 @@ import org.slf4j.Logger ; import org.slf4j.LoggerFactory ; -import com.spatial4j.core.shape.Shape ; +import org.locationtech.spatial4j.shape.Shape ; public class SpatialIndexSolr implements SpatialIndex { private static Logger log = LoggerFactory.getLogger(SpatialIndexSolr.class); diff --git a/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialQuery.java b/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialQuery.java index b860f2fc219..058e1bdaf4c 100644 --- a/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialQuery.java +++ b/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialQuery.java @@ -18,7 +18,7 @@ package org.apache.jena.query.spatial; -import com.spatial4j.core.context.SpatialContext ; +import org.locationtech.spatial4j.context.SpatialContext ; import org.apache.jena.query.spatial.assembler.SpatialAssembler ; import org.apache.jena.query.spatial.pfunction.library.* ; @@ -51,7 +51,7 @@ public class SpatialQuery public static SpatialContext ctx = SpatialContext.GEO; // an optional feature for WKT literals, loaded when necessary, but not required - public static final String JTS_SPATIAL_CONTEXT_FACTORY_CLASS = "com.spatial4j.core.context.jts.JtsSpatialContextFactory"; + public static final String JTS_SPATIAL_CONTEXT_FACTORY_CLASS = "org.locationtech.spatial4j.context.jts.JtsSpatialContextFactory"; static { JenaSystem.init(); } diff --git a/jena-spatial/src/main/java/org/apache/jena/query/spatial/assembler/EntityDefinitionAssembler.java b/jena-spatial/src/main/java/org/apache/jena/query/spatial/assembler/EntityDefinitionAssembler.java index dc19ee5000b..d32f72203e3 100644 --- a/jena-spatial/src/main/java/org/apache/jena/query/spatial/assembler/EntityDefinitionAssembler.java +++ b/jena-spatial/src/main/java/org/apache/jena/query/spatial/assembler/EntityDefinitionAssembler.java @@ -48,7 +48,7 @@ public class EntityDefinitionAssembler extends AssemblerBase implements Assemble ) ; spatial:hasWKTPredicates (<#wkt_1> <#wkt_2>) ; spatial:spatialContextFactory - "com.spatial4j.core.context.jts.JtsSpatialContextFactory" . + "org.locationtech.spatial4j.context.jts.JtsSpatialContextFactory" . */ @Override diff --git a/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/SpatialMatch.java b/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/SpatialMatch.java index 0d8275ca053..3c0c6609c04 100644 --- a/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/SpatialMatch.java +++ b/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/SpatialMatch.java @@ -22,7 +22,7 @@ import org.apache.jena.query.spatial.SpatialQuery; import org.apache.lucene.spatial.query.SpatialOperation; -import com.spatial4j.core.shape.Shape; +import org.locationtech.spatial4j.shape.Shape; public class SpatialMatch { diff --git a/jena-spatial/src/test/java/org/apache/jena/query/spatial/AbstractTestIndexingSpatialData.java b/jena-spatial/src/test/java/org/apache/jena/query/spatial/AbstractTestIndexingSpatialData.java index 000b6ff4c8b..864b16b9638 100644 --- a/jena-spatial/src/test/java/org/apache/jena/query/spatial/AbstractTestIndexingSpatialData.java +++ b/jena-spatial/src/test/java/org/apache/jena/query/spatial/AbstractTestIndexingSpatialData.java @@ -26,7 +26,7 @@ import org.junit.Test; import static org.junit.Assert.fail; -import com.spatial4j.core.exception.InvalidShapeException; +import org.locationtech.spatial4j.exception.InvalidShapeException; public class AbstractTestIndexingSpatialData extends AbstractTestDatasetWithSpatialIndex { diff --git a/jena-spatial/src/test/java/org/apache/jena/query/spatial/assembler/TestEntityDefinitionAssembler.java b/jena-spatial/src/test/java/org/apache/jena/query/spatial/assembler/TestEntityDefinitionAssembler.java index 12376b3da88..4e2c4d5f44b 100644 --- a/jena-spatial/src/test/java/org/apache/jena/query/spatial/assembler/TestEntityDefinitionAssembler.java +++ b/jena-spatial/src/test/java/org/apache/jena/query/spatial/assembler/TestEntityDefinitionAssembler.java @@ -105,10 +105,10 @@ public void EntityHasSpatialContextFactory() { EntityDefinitionAssembler emAssembler = new EntityDefinitionAssembler(); emAssembler.open(null, spec3, null); if (jts_lib_ready) { - assertEquals("com.spatial4j.core.context.jts.JtsSpatialContext", + assertEquals("org.locationtech.spatial4j.context.jts.JtsSpatialContext", SpatialQuery.ctx.getClass().getName()); } else { - assertEquals("com.spatial4j.core.context.SpatialContext", + assertEquals("org.locationtech.spatial4j.context.SpatialContext", SpatialQuery.ctx.getClass().getName()); } diff --git a/jena-text/src/main/java/org/apache/jena/query/text/analyzer/ConfigurableAnalyzer.java b/jena-text/src/main/java/org/apache/jena/query/text/analyzer/ConfigurableAnalyzer.java index 8960ddbeaa3..20084450d31 100644 --- a/jena-text/src/main/java/org/apache/jena/query/text/analyzer/ConfigurableAnalyzer.java +++ b/jena-text/src/main/java/org/apache/jena/query/text/analyzer/ConfigurableAnalyzer.java @@ -86,4 +86,13 @@ protected TokenStreamComponents createComponents(String fieldName) { return new TokenStreamComponents(source, stream); } + @Override + protected TokenStream normalize(String fieldName, TokenStream in) { + TokenStream stream = in; + for (String filter : this.filters) { + stream = getTokenFilter(filter, stream); + } + return stream; + } + } diff --git a/jena-text/src/main/java/org/apache/jena/query/text/assembler/StandardAnalyzerAssembler.java b/jena-text/src/main/java/org/apache/jena/query/text/assembler/StandardAnalyzerAssembler.java index e221d19cd40..a4e0070c266 100644 --- a/jena-text/src/main/java/org/apache/jena/query/text/assembler/StandardAnalyzerAssembler.java +++ b/jena-text/src/main/java/org/apache/jena/query/text/assembler/StandardAnalyzerAssembler.java @@ -32,7 +32,7 @@ import org.apache.jena.vocabulary.RDF ; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.standard.StandardAnalyzer; -import org.apache.lucene.analysis.util.CharArraySet; +import org.apache.lucene.analysis.CharArraySet; /** * Assembler to create standard analyzers with keyword list. From 45c0fe7d8d266074df65bf4b3745e7f42b4af5a4 Mon Sep 17 00:00:00 2001 From: Osma Suominen Date: Fri, 3 Mar 2017 17:38:52 +0200 Subject: [PATCH 3/3] JENA-1301: Remove Solr support from jena-text and jena-spatial --- jena-fuseki1/config-tdb-text.ttl | 8 - jena-parent/pom.xml | 22 -- jena-spatial/pom.xml | 30 --- .../java/examples/JenaSpatialExample1.java | 23 +- .../src/main/java/jena/spatialindexdump.java | 4 - .../query/spatial/SpatialDatasetFactory.java | 21 -- .../query/spatial/SpatialIndexLucene.java | 1 - .../jena/query/spatial/SpatialIndexSolr.java | 177 ------------ .../jena/query/spatial/SpatialQueryFuncs.java | 6 +- .../spatial/assembler/SpatialAssembler.java | 1 - .../assembler/SpatialIndexSolrAssembler.java | 81 ------ .../query/spatial/assembler/SpatialVocab.java | 3 - .../jena/query/spatial/SpatialSearchUtil.java | 18 +- .../apache/jena/query/spatial/TS_Spatial.java | 11 - .../TestIndexingSpatialDataWithSolr.java | 40 --- .../AbstractTestSpatialAssembler.java | 9 +- .../TestSpatialIndexSolrAssembler.java | 38 --- ...estEastPFWithEmbeddedSolrSpatialIndex.java | 47 ---- ...ectsBoxPFWithEmbeddedSolrSpatialIndex.java | 44 --- ...sNearByPFWithEmbeddedSolrSpatialIndex.java | 41 --- ...thinBoxPFWithEmbeddedSolrSpatialIndex.java | 47 ---- ...nCirclePFWithEmbeddedSolrSpatialIndex.java | 41 --- ...stNorthPFWithEmbeddedSolrSpatialIndex.java | 47 ---- ...stSouthPFWithEmbeddedSolrSpatialIndex.java | 47 ---- ...estWestPFWithEmbeddedSolrSpatialIndex.java | 47 ---- .../SolrARQCollection/conf/schema.xml | 56 ---- .../SolrARQCollection/conf/solrconfig.xml | 77 ------ .../src/test/resources/SolrHome/solr.xml | 8 - .../src/test/resources/log4j.properties | 7 +- .../spatial-config-spatialindexer.ttl | 2 - .../src/test/resources/spatial-config.ttl | 2 - .../test/resources/spatial-solr-config.ttl | 51 ---- jena-text/pom.xml | 34 --- .../src/main/java/jena/textindexdump.java | 4 - .../jena/query/text/TextDatasetFactory.java | 22 -- .../jena/query/text/TextIndexLucene.java | 2 - .../apache/jena/query/text/TextIndexSolr.java | 251 ------------------ .../jena/query/text/TextQueryFuncs.java | 6 +- .../apache/jena/query/text/TextQueryPF.java | 2 +- .../query/text/assembler/TextAssembler.java | 1 - .../assembler/TextIndexSolrAssembler.java | 68 ----- .../jena/query/text/assembler/TextVocab.java | 2 - .../org/apache/jena/query/text/TS_Text.java | 6 - .../TestDatasetWithEmbeddedSolrTextIndex.java | 54 ---- .../assembler/TestTextIndexSolrAssembler.java | 69 ----- jena-text/src/test/resources/log4j.properties | 5 - .../testing/TextQuery/text-config-union.ttl | 2 - jena-text/testing/TextQuery/text-config.ttl | 2 - .../testing/TextQuery/text-solr-config.ttl | 45 ---- jena-text/text-config.ttl | 2 - 50 files changed, 11 insertions(+), 1623 deletions(-) delete mode 100644 jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialIndexSolr.java delete mode 100644 jena-spatial/src/main/java/org/apache/jena/query/spatial/assembler/SpatialIndexSolrAssembler.java delete mode 100644 jena-spatial/src/test/java/org/apache/jena/query/spatial/TestIndexingSpatialDataWithSolr.java delete mode 100644 jena-spatial/src/test/java/org/apache/jena/query/spatial/assembler/TestSpatialIndexSolrAssembler.java delete mode 100644 jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/solr/TestEastPFWithEmbeddedSolrSpatialIndex.java delete mode 100644 jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/solr/TestIntersectsBoxPFWithEmbeddedSolrSpatialIndex.java delete mode 100644 jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/solr/TestIsNearByPFWithEmbeddedSolrSpatialIndex.java delete mode 100644 jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/solr/TestIsWithinBoxPFWithEmbeddedSolrSpatialIndex.java delete mode 100644 jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/solr/TestIsWithinCirclePFWithEmbeddedSolrSpatialIndex.java delete mode 100644 jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/solr/TestNorthPFWithEmbeddedSolrSpatialIndex.java delete mode 100644 jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/solr/TestSouthPFWithEmbeddedSolrSpatialIndex.java delete mode 100644 jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/solr/TestWestPFWithEmbeddedSolrSpatialIndex.java delete mode 100644 jena-spatial/src/test/resources/SolrHome/SolrARQCollection/conf/schema.xml delete mode 100644 jena-spatial/src/test/resources/SolrHome/SolrARQCollection/conf/solrconfig.xml delete mode 100644 jena-spatial/src/test/resources/SolrHome/solr.xml delete mode 100644 jena-spatial/src/test/resources/spatial-solr-config.ttl delete mode 100644 jena-text/src/main/java/org/apache/jena/query/text/TextIndexSolr.java delete mode 100644 jena-text/src/main/java/org/apache/jena/query/text/assembler/TextIndexSolrAssembler.java delete mode 100644 jena-text/src/test/java/org/apache/jena/query/text/TestDatasetWithEmbeddedSolrTextIndex.java delete mode 100644 jena-text/src/test/java/org/apache/jena/query/text/assembler/TestTextIndexSolrAssembler.java delete mode 100644 jena-text/testing/TextQuery/text-solr-config.ttl diff --git a/jena-fuseki1/config-tdb-text.ttl b/jena-fuseki1/config-tdb-text.ttl index e0ff09dc91e..f81c792d907 100644 --- a/jena-fuseki1/config-tdb-text.ttl +++ b/jena-fuseki1/config-tdb-text.ttl @@ -44,7 +44,6 @@ tdb:GraphTDB rdfs:subClassOf ja:Model . # Text [] ja:loadClass "org.apache.jena.query.text.TextQuery" . text:TextDataset rdfs:subClassOf ja:RDFDataset . -#text:TextIndexSolr rdfs:subClassOf text:TextIndex . text:TextIndexLucene rdfs:subClassOf text:TextIndex . ## --------------------------------------------------------------- @@ -63,7 +62,6 @@ text:TextIndexLucene rdfs:subClassOf text:TextIndex . <#text_dataset> rdf:type text:TextDataset ; text:dataset <#dataset> ; - ##text:index <#indexSolr> ; text:index <#indexLucene> ; . @@ -72,12 +70,6 @@ text:TextIndexLucene rdfs:subClassOf text:TextIndex . ##tdb:unionDefaultGraph true ; . -<#indexSolr> a text:TextIndexSolr ; - #text:server ; - text:server ; - text:entityMap <#entMap> ; - . - <#indexLucene> a text:TextIndexLucene ; text:directory ; ##text:directory "mem" ; diff --git a/jena-parent/pom.xml b/jena-parent/pom.xml index 5e0c8a9fb51..78035798be5 100644 --- a/jena-parent/pom.xml +++ b/jena-parent/pom.xml @@ -62,7 +62,6 @@ 1.3 0.6 - 4.5.2 4.4.4 - - - - solr-solrj - org.apache.solr - ${ver.solr} - - - org.slf4j - slf4j-api - - - org.slf4j - slf4j-jdk14 - - - - org.apache.lucene diff --git a/jena-spatial/pom.xml b/jena-spatial/pom.xml index fc8f9487d96..103ab775878 100644 --- a/jena-spatial/pom.xml +++ b/jena-spatial/pom.xml @@ -93,36 +93,6 @@ spatial4j - - solr-solrj - org.apache.solr - - diff --git a/jena-spatial/src/main/java/examples/JenaSpatialExample1.java b/jena-spatial/src/main/java/examples/JenaSpatialExample1.java index 03f77e7ce44..992f5db6042 100644 --- a/jena-spatial/src/main/java/examples/JenaSpatialExample1.java +++ b/jena-spatial/src/main/java/examples/JenaSpatialExample1.java @@ -47,15 +47,11 @@ public class JenaSpatialExample1 { private static final File LUCENE_INDEX_DIR = new File(LUCENE_INDEX_PATH); private static final String LUCENE_TDB_PATH = "target/test/TDB"; private static final File LUCENE_TDB_DIR = new File(LUCENE_TDB_PATH); - // or Apache Solr for a large scale enterprise search application - private static final String SOLR_DATA_PATH = "src/test/resources/SolrHome/SolrARQCollection/data"; - private static final File SOLR_DATA_DIR = new File(SOLR_DATA_PATH); public static void main(String... argv) throws IOException { Dataset spatialDataset = initInMemoryDatasetWithLuceneSpatialIndex(LUCENE_INDEX_DIR); //Dataset spatialDataset = initTDBDatasetWithLuceneSpatialIndex(indexDir, TDBDir); //Dataset spatialDataset = createLuceneAssembler() ; - //Dataset spatialDataset = createSolrAssembler() ; loadData(spatialDataset, "src/test/resources/geoarq-data-1.ttl"); queryData(spatialDataset); @@ -70,16 +66,7 @@ private static void destroy(Dataset spatialDataset){ deleteOldFiles(LUCENE_INDEX_DIR); deleteOldFiles(LUCENE_TDB_DIR); } - -// else if (index instanceof SpatialIndexSolr){ -// SolrServer server = ((SpatialIndexSolr)index).getServer(); -// -// if (server instanceof EmbeddedSolrServer){ -// server.shutdown(); -// deleteOldFiles(SOLR_DATA_DIR); -// } -// } - + } private static void emptyAndDeleteDirectory(File dir) { File[] contents = dir.listFiles() ; @@ -158,14 +145,6 @@ public static Dataset createLuceneAssembler() { return ds; } - public static Dataset createSolrAssembler() { - log.info("Construct solr spatial dataset using an assembler description"); - - Dataset ds = DatasetFactory.assemble("src/test/resources/spatial-solr-config.ttl", - "http://localhost/jena_example/#spatial_dataset"); - return ds; - } - public static void loadData(Dataset spatialDataset, String file) { log.info("Start loading"); long startTime = System.nanoTime(); diff --git a/jena-spatial/src/main/java/jena/spatialindexdump.java b/jena-spatial/src/main/java/jena/spatialindexdump.java index 29a3d5df747..e02532c0710 100644 --- a/jena-spatial/src/main/java/jena/spatialindexdump.java +++ b/jena-spatial/src/main/java/jena/spatialindexdump.java @@ -89,14 +89,10 @@ protected void exec() { if ( spatialIndex instanceof SpatialIndexLucene ) dump((SpatialIndexLucene)spatialIndex) ; -// else if ( spatialIndex instanceof SpatialIndexSolr ) -// dump((SpatialIndexSolr)spatialIndex) ; else System.err.println("Unsupported index type : "+Lib.className(spatialIndex)) ; } -// private static void dump(SpatialIndexSolr spatialIndex) { System.err.println("Not implemented : dump Solr index") ; } - private static void dump(SpatialIndexLucene spatialIndex) { try { Directory directory = spatialIndex.getDirectory() ; diff --git a/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialDatasetFactory.java b/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialDatasetFactory.java index 056a524ec29..2516d59bbbb 100644 --- a/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialDatasetFactory.java +++ b/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialDatasetFactory.java @@ -25,7 +25,6 @@ import org.apache.jena.sparql.core.assembler.AssemblerUtils ; import org.apache.jena.system.JenaSystem ; import org.apache.lucene.store.Directory; -import org.apache.solr.client.solrj.SolrServer; public class SpatialDatasetFactory { @@ -78,25 +77,5 @@ public static DatasetGraph createLucene(DatasetGraph base, Directory directory, return create(base, index) ; } - /** Create a Solr TextIndex */ - public static SpatialIndex createSolrIndex(SolrServer server, EntityDefinition entMap) - { - SpatialIndex index = new SpatialIndexSolr(server, entMap) ; - return index ; - } - - /** Create a text-indexed dataset, using Solr */ - public static Dataset createSolrIndex(Dataset base, SolrServer server, EntityDefinition entMap) - { - SpatialIndex index = createSolrIndex(server, entMap) ; - return create(base, index) ; - } - - /** Create a text-indexed dataset, using Solr */ - public static DatasetGraph createSolrIndex(DatasetGraph base, SolrServer server, EntityDefinition entMap) - { - SpatialIndex index = createSolrIndex(server, entMap) ; - return create(base, index) ; - } } diff --git a/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialIndexLucene.java b/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialIndexLucene.java index 440df4dc993..92a250d5353 100644 --- a/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialIndexLucene.java +++ b/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialIndexLucene.java @@ -196,7 +196,6 @@ public List query(Shape shape, int limit, SpatialOperation operation) { List results = new ArrayList<>(); - // Align and DRY with Solr. for (ScoreDoc sd : docs.scoreDocs) { Document doc = indexSearcher.doc(sd.doc); String[] values = doc.getValues(docDef.getEntityField()); diff --git a/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialIndexSolr.java b/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialIndexSolr.java deleted file mode 100644 index 49a6fb8e894..00000000000 --- a/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialIndexSolr.java +++ /dev/null @@ -1,177 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.jena.query.spatial; - -import java.util.ArrayList ; -import java.util.List ; - -import org.apache.jena.graph.Node ; -import org.apache.jena.sparql.util.NodeFactoryExtra ; -import org.apache.lucene.spatial.SpatialStrategy ; -import org.apache.lucene.spatial.prefix.RecursivePrefixTreeStrategy ; -import org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree ; -import org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree ; -import org.apache.lucene.spatial.query.SpatialOperation ; -import org.apache.solr.client.solrj.SolrQuery ; -import org.apache.solr.client.solrj.SolrServer ; -import org.apache.solr.client.solrj.SolrServerException ; -import org.apache.solr.client.solrj.response.QueryResponse ; -import org.apache.solr.common.SolrDocument ; -import org.apache.solr.common.SolrDocumentList ; -import org.apache.solr.common.SolrInputDocument ; -import org.slf4j.Logger ; -import org.slf4j.LoggerFactory ; - -import org.locationtech.spatial4j.shape.Shape ; - -public class SpatialIndexSolr implements SpatialIndex { - private static Logger log = LoggerFactory.getLogger(SpatialIndexSolr.class); - private final SolrServer solrServer; - private EntityDefinition docDef; - private SpatialPrefixTree grid; - - /** - * The Lucene spatial {@link SpatialStrategy} encapsulates an approach to - * indexing and searching shapes, and providing distance values for them. - * It's a simple API to unify different approaches. You might use more than - * one strategy for a shape as each strategy has its strengths and - * weaknesses. - *

- * Note that these are initialized with a field name. - */ - private SpatialStrategy strategy; - - public SpatialIndexSolr(SolrServer server, EntityDefinition def) { - this.solrServer = server; - this.docDef = def; - - int maxLevels = 11;// results in sub-meter precision for geohash - // This can also be constructed from SpatialPrefixTreeFactory - grid = new GeohashPrefixTree(SpatialQuery.ctx, maxLevels); - - this.strategy = new RecursivePrefixTreeStrategy(grid, def.getGeoField()); - } - - @Override - public void startIndexing() { - } - - @Override - public void finishIndexing() { - try { - solrServer.commit(); - } catch (Exception ex) { - exception(ex); - } - } - - @Override - public void abortIndexing() { - try { - solrServer.rollback(); - } catch (Exception ex) { - exception(ex); - } - } - - @Override - public void close() { - if (solrServer != null) - solrServer.shutdown(); - } - - @Override - public void add(String entityURI, Shape... shapes) { - - // log.info("Add entity: "+entityURI) ; - try { - SolrInputDocument doc = solrDoc(entityURI, shapes); - solrServer.add(doc); - } catch (Exception e) { - exception(e); - } - } - - @SuppressWarnings("deprecation") - private SolrInputDocument solrDoc(String entityURI, Shape... shapes) { - SolrInputDocument doc = new SolrInputDocument(); - doc.addField(docDef.getEntityField(), entityURI); - if (shapes.length != 1) { - throw new SpatialIndexException( - "Solr spatial only supports indexing one shape a time, but provided: " - + shapes.length + " shapes."); - } - doc.addField(docDef.getGeoField(), SpatialQuery.ctx.toString(shapes[0])); - return doc; - } - - @Override - public List query(Shape shape, int limit, SpatialOperation operation) { - - SolrDocumentList solrResults = solrQuery(shape, limit, operation); - List results = new ArrayList<>(); - - for (SolrDocument sd : solrResults) { - String str = (String) sd.getFieldValue(docDef.getEntityField()); - Node n = SpatialQueryFuncs.stringToNode(str) ; - results.add(n) ; - } - - if (limit > 0 && results.size() > limit) - results = results.subList(0, limit); - - return results; - } - - @SuppressWarnings("deprecation") - private SolrDocumentList solrQuery(Shape shape, int limit, - SpatialOperation operation) { - SolrQuery sq = new SolrQuery(); - sq.setQuery("*:*"); - sq.setFilterQueries(docDef.getGeoField() + ":\"" + operation.toString() - + "(" + SpatialQuery.ctx.toString(shape) + ") distErrPct=0\""); - //System.out.println("SolrQuery: " +sq.toString()); - try { - QueryResponse rsp = solrServer.query(sq); - SolrDocumentList docs = rsp.getResults(); - return docs; - } catch (SolrServerException e) { - exception(e); - return null; - } - } - - @Override - public EntityDefinition getDocDef() { - return docDef; - } - - private Node entryToNode(String v) { - // TEMP - return NodeFactoryExtra.createLiteralNode(v, null, null); - } - - public SolrServer getServer() { - return solrServer; - } - - private static Void exception(Exception ex) { - throw new SpatialIndexException(ex); - } -} diff --git a/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialQueryFuncs.java b/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialQueryFuncs.java index 48011c1a6f7..b967a41ace8 100644 --- a/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialQueryFuncs.java +++ b/jena-spatial/src/main/java/org/apache/jena/query/spatial/SpatialQueryFuncs.java @@ -23,7 +23,7 @@ public class SpatialQueryFuncs { - /** Create a string to put in a Lucene/Solr index for the subject node */ + /** Create a string to put in a Lucene index for the subject node */ public static String subjectToString(Node s) { if ( s == null ) throw new IllegalArgumentException("Subject node can not be null") ; @@ -32,7 +32,7 @@ public static String subjectToString(Node s) { return nodeToString(s) ; } - /** Create a string to put in a Lucene/Solr index for a graph node */ + /** Create a string to put in a Lucene index for a graph node */ public static String graphNodeToString(Node g) { if ( g == null ) return null ; @@ -45,7 +45,7 @@ private static String nodeToString(Node n) { return (n.isURI() ) ? n.getURI() : "_:" + n.getBlankNodeLabel() ; } - /** Recover a Node from a stored Lucene/Solr string */ + /** Recover a Node from a stored Lucene string */ public static Node stringToNode(String v) { if ( v.startsWith("_:") ) { v = v.substring("_:".length()) ; diff --git a/jena-spatial/src/main/java/org/apache/jena/query/spatial/assembler/SpatialAssembler.java b/jena-spatial/src/main/java/org/apache/jena/query/spatial/assembler/SpatialAssembler.java index a1a4b769e3d..2a16821ae9c 100644 --- a/jena-spatial/src/main/java/org/apache/jena/query/spatial/assembler/SpatialAssembler.java +++ b/jena-spatial/src/main/java/org/apache/jena/query/spatial/assembler/SpatialAssembler.java @@ -29,7 +29,6 @@ public static void init() AssemblerUtils.registerDataset(SpatialVocab.spatialDataset, new SpatialDatasetAssembler()) ; Assembler.general.implementWith(SpatialVocab.definition, new EntityDefinitionAssembler()) ; - Assembler.general.implementWith(SpatialVocab.spatialIndexSolr, new SpatialIndexSolrAssembler()) ; Assembler.general.implementWith(SpatialVocab.spatialIndexLucene, new SpatialIndexLuceneAssembler()) ; } } diff --git a/jena-spatial/src/main/java/org/apache/jena/query/spatial/assembler/SpatialIndexSolrAssembler.java b/jena-spatial/src/main/java/org/apache/jena/query/spatial/assembler/SpatialIndexSolrAssembler.java deleted file mode 100644 index 451e1b5db55..00000000000 --- a/jena-spatial/src/main/java/org/apache/jena/query/spatial/assembler/SpatialIndexSolrAssembler.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.jena.query.spatial.assembler; - -import static org.apache.jena.query.spatial.assembler.SpatialVocab.pDefinition ; -import static org.apache.jena.query.spatial.assembler.SpatialVocab.pServer ; -import org.apache.jena.assembler.Assembler ; -import org.apache.jena.assembler.Mode ; -import org.apache.jena.assembler.assemblers.AssemblerBase ; -import org.apache.jena.query.spatial.EntityDefinition ; -import org.apache.jena.query.spatial.SpatialDatasetFactory ; -import org.apache.jena.query.spatial.SpatialIndex ; -import org.apache.jena.query.spatial.SpatialIndexException ; -import org.apache.jena.rdf.model.Resource ; -import org.apache.jena.sparql.util.graph.GraphUtils ; -import org.apache.solr.client.solrj.SolrServer ; -import org.apache.solr.client.solrj.impl.HttpSolrServer ; - -public class SpatialIndexSolrAssembler extends AssemblerBase { - /* - * <#index> a :TextIndexSolr ; text:server - * ; #text:server - * ; text:entityMap <#endMap> ; . - */ - - @Override - public SpatialIndex open(Assembler a, Resource root, Mode mode) { - String uri = GraphUtils.getResourceValue(root, pServer).getURI(); - SolrServer server; - if (uri.startsWith("embedded:")) { - throw new SpatialIndexException("Embedded Solr server not supported (change code and dependencies to enable)") ; -// try { -// if ( ! GraphUtils.exactlyOneProperty(root, pSolrHome) ) -// throw new SpatialIndexException("No 'spatial:solrHome' property on EmbeddedSolrServer "+root) ; -// -// RDFNode n = root.getProperty(pSolrHome).getObject() ; -// -// if (n.isLiteral()){ -// throw new SpatialIndexException ("No 'spatial:solrHome' property on EmbeddedSolrServer "+root+ " is a literal and not a Resource/URI"); -// } -// Resource x = n.asResource() ; -// String path = IRILib.IRIToFilename(x.getURI()) ; -// -// System.setProperty("solr.solr.home", path); -// String coreName = uri.substring("embedded:".length()); -// CoreContainer.Initializer initializer = new CoreContainer.Initializer(); -// CoreContainer coreContainer = initializer.initialize(); -// server = new EmbeddedSolrServer(coreContainer, coreName); -// } catch (FileNotFoundException e) { -// throw new SpatialIndexException(e); -// // throw new -// // SpatialIndexException("Embedded Solr server not supported (change code and dependencies to enable)") -// // ; -// } - } else if (uri.startsWith("http://")) { - server = new HttpSolrServer(uri); - } else - throw new SpatialIndexException( - "URI for the server must begin 'http://'"); - - Resource r = GraphUtils.getResourceValue(root, pDefinition); - EntityDefinition docDef = (EntityDefinition) a.open(r); - return SpatialDatasetFactory.createSolrIndex(server, docDef); - } -} diff --git a/jena-spatial/src/main/java/org/apache/jena/query/spatial/assembler/SpatialVocab.java b/jena-spatial/src/main/java/org/apache/jena/query/spatial/assembler/SpatialVocab.java index 0759317428b..73772200433 100644 --- a/jena-spatial/src/main/java/org/apache/jena/query/spatial/assembler/SpatialVocab.java +++ b/jena-spatial/src/main/java/org/apache/jena/query/spatial/assembler/SpatialVocab.java @@ -31,10 +31,7 @@ public class SpatialVocab public static final Property pIndex = Vocab.property(NS, "index") ; public static final Resource spatialIndex = Vocab.resource(NS, "SpatialIndex") ; - public static final Resource spatialIndexSolr = Vocab.resource(NS, "SpatialIndexSolr") ; public static final Resource spatialIndexLucene = Vocab.resource(NS, "SpatialIndexLucene") ; - public static final Property pServer = Vocab.property(NS, "server") ; // Solr - public static final Property pSolrHome = Vocab.property(NS, "solrHome") ; // EmbeddedSolrServer public static final Property pDirectory = Vocab.property(NS, "directory") ; // Lucene public static final Property pDefinition = Vocab.property(NS, "definition") ; diff --git a/jena-spatial/src/test/java/org/apache/jena/query/spatial/SpatialSearchUtil.java b/jena-spatial/src/test/java/org/apache/jena/query/spatial/SpatialSearchUtil.java index 8d0453ad494..380ac70a447 100644 --- a/jena-spatial/src/test/java/org/apache/jena/query/spatial/SpatialSearchUtil.java +++ b/jena-spatial/src/test/java/org/apache/jena/query/spatial/SpatialSearchUtil.java @@ -37,12 +37,6 @@ public class SpatialSearchUtil { private static final String LUCENE_INDEX_PATH = "target/test/LuceneSpatialIndex"; private static final File LUCENE_Index_DIR = new File(LUCENE_INDEX_PATH); - private static final String SOLR_DATA_PATH = "target/test/SolrARQCollection/data"; - private static final File SOLR_DATA_DIR = new File(SOLR_DATA_PATH); - private static final String SOLR_INDEX_PATH = SOLR_DATA_PATH + "/index"; - private static final File SOLR_INDEX_DIR = new File(SOLR_INDEX_PATH); - private static final String SOLR_TEST_ASSEM = "src/test/resources/spatial-solr-config.ttl" ; - public static void emptyAndDeleteDirectory(File dir) { File[] contents = dir.listFiles() ; if (contents != null) { @@ -68,13 +62,6 @@ public static void createEmptyIndex(File indexDir) { } } - public static Dataset initInMemoryDatasetWithSolrSpatitalIndex() { - SpatialSearchUtil.deleteOldFiles(SOLR_DATA_DIR ); - SOLR_INDEX_DIR.mkdirs(); - SpatialSearchUtil.createEmptyIndex(SOLR_INDEX_DIR); - return SpatialDatasetFactory.create(SOLR_TEST_ASSEM) ; - } - public static Dataset initInMemoryDatasetWithLuceneSpatitalIndex() throws IOException{ return initInMemoryDatasetWithLuceneSpatitalIndex(LUCENE_Index_DIR); } @@ -96,10 +83,7 @@ public static Dataset initTDBDatasetWithLuceneSpatitalIndex(File indexDir, File public static void deleteOldLuceneIndexDir() { deleteOldFiles(LUCENE_Index_DIR); } - public static void deleteOldSolrDataDir() { - deleteOldFiles(SOLR_DATA_DIR); - } - + public static void deleteOldFiles(File indexDir) { if (indexDir.exists()) emptyAndDeleteDirectory(indexDir); diff --git a/jena-spatial/src/test/java/org/apache/jena/query/spatial/TS_Spatial.java b/jena-spatial/src/test/java/org/apache/jena/query/spatial/TS_Spatial.java index 2eda02057d9..e7e3f298e39 100644 --- a/jena-spatial/src/test/java/org/apache/jena/query/spatial/TS_Spatial.java +++ b/jena-spatial/src/test/java/org/apache/jena/query/spatial/TS_Spatial.java @@ -54,19 +54,8 @@ TestSouthPFWithLuceneSpatialIndex.class, TestEastPFWithLuceneSpatialIndex.class, TestWestPFWithLuceneSpatialIndex.class, - -// TestIsWithinCirclePFWithEmbeddedSolrSpatialIndex.class, -// TestIsNearByPFWithEmbeddedSolrSpatialIndex.class, -// TestIsWithinBoxPFWithEmbeddedSolrSpatialIndex.class, -// TestIntersectsBoxPFWithEmbeddedSolrSpatialIndex.class, -// TestNorthPFWithEmbeddedSolrSpatialIndex.class, -// TestSouthPFWithEmbeddedSolrSpatialIndex.class, -// TestEastPFWithEmbeddedSolrSpatialIndex.class, -// TestWestPFWithEmbeddedSolrSpatialIndex.class, - TestTDBDatasetWithLuceneSpatialIndex.class, TestIndexingSpatialDataWithLucene.class, -// TestIndexingSpatialDataWithSolr.class, TestEntityDefinitionAssembler.class, TestSpatialDatasetAssembler.class, diff --git a/jena-spatial/src/test/java/org/apache/jena/query/spatial/TestIndexingSpatialDataWithSolr.java b/jena-spatial/src/test/java/org/apache/jena/query/spatial/TestIndexingSpatialDataWithSolr.java deleted file mode 100644 index d3f70cd8a00..00000000000 --- a/jena-spatial/src/test/java/org/apache/jena/query/spatial/TestIndexingSpatialDataWithSolr.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.jena.query.spatial; - -import org.junit.After; -import org.junit.Before; - -public class TestIndexingSpatialDataWithSolr extends - AbstractTestIndexingSpatialData { - - @Before - public void init() { - dataset = SpatialSearchUtil.initInMemoryDatasetWithSolrSpatitalIndex(); - } - - @After - public void destroy() { - SpatialIndexSolr index = (SpatialIndexSolr) dataset.getContext().get( - SpatialQuery.spatialIndex); - index.getServer().shutdown(); - SpatialSearchUtil.deleteOldSolrDataDir(); - } - -} diff --git a/jena-spatial/src/test/java/org/apache/jena/query/spatial/assembler/AbstractTestSpatialAssembler.java b/jena-spatial/src/test/java/org/apache/jena/query/spatial/assembler/AbstractTestSpatialAssembler.java index 933b0a55dfd..4577e2750de 100644 --- a/jena-spatial/src/test/java/org/apache/jena/query/spatial/assembler/AbstractTestSpatialAssembler.java +++ b/jena-spatial/src/test/java/org/apache/jena/query/spatial/assembler/AbstractTestSpatialAssembler.java @@ -30,7 +30,6 @@ public abstract class AbstractTestSpatialAssembler { private static final String TESTBASE = "http://example.org/abstractTestSpatialAssembler/"; protected static final Resource SIMPLE_DATASET_SPEC; protected static final Resource SIMPLE_LUCENE_INDEX_SPEC; - protected static final Resource SIMPLE_SOLR_INDEX_SPEC; protected static final Resource SIMPLE_ENTITY_DEFINITION_SPEC; static { @@ -66,12 +65,6 @@ public abstract class AbstractTestSpatialAssembler { .addProperty(RDF.type, SpatialVocab.spatialIndexLucene) .addProperty(SpatialVocab.pDirectory, model.createResource("file:target/test/simpleLuceneIndex")) .addProperty(SpatialVocab.pDefinition, SIMPLE_ENTITY_DEFINITION_SPEC); - - SIMPLE_SOLR_INDEX_SPEC = - model.createResource(TESTBASE + "simpleSolrIndexSpec") - .addProperty(RDF.type, SpatialVocab.spatialIndexSolr) - .addProperty(SpatialVocab.pServer, model.createResource("http://localhost:8080/solr")) - .addProperty(SpatialVocab.pDefinition, SIMPLE_ENTITY_DEFINITION_SPEC); - } + } } diff --git a/jena-spatial/src/test/java/org/apache/jena/query/spatial/assembler/TestSpatialIndexSolrAssembler.java b/jena-spatial/src/test/java/org/apache/jena/query/spatial/assembler/TestSpatialIndexSolrAssembler.java deleted file mode 100644 index 6fbf3b9e64e..00000000000 --- a/jena-spatial/src/test/java/org/apache/jena/query/spatial/assembler/TestSpatialIndexSolrAssembler.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.jena.query.spatial.assembler; - -import static org.junit.Assert.assertEquals; -import org.apache.jena.assembler.Assembler ; -import org.apache.jena.query.spatial.SpatialIndexSolr; -import org.junit.Test; - -public class TestSpatialIndexSolrAssembler extends AbstractTestSpatialAssembler { - - @Test public void testIndexHasEntityMap() { - SpatialIndexSolr indexSolr = (SpatialIndexSolr) Assembler.general.open(SIMPLE_SOLR_INDEX_SPEC); - assertEquals("uri", indexSolr.getDocDef().getEntityField()); - assertEquals("geo", indexSolr.getDocDef().getGeoField()); - } - - static { - SpatialAssembler.init(); - } - -} diff --git a/jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/solr/TestEastPFWithEmbeddedSolrSpatialIndex.java b/jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/solr/TestEastPFWithEmbeddedSolrSpatialIndex.java deleted file mode 100644 index 4b58dce0a57..00000000000 --- a/jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/solr/TestEastPFWithEmbeddedSolrSpatialIndex.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.jena.query.spatial.pfunction.solr; - -import org.apache.jena.query.spatial.SpatialIndexSolr; -import org.apache.jena.query.spatial.SpatialQuery; -import org.apache.jena.query.spatial.SpatialSearchUtil; -import org.apache.jena.query.spatial.pfunction.AbstractTestEastPF; -import org.junit.After; -import org.junit.Before; - -/** - * This abstract class defines a setup configuration for a dataset with a Lucene - * index. - */ -public class TestEastPFWithEmbeddedSolrSpatialIndex extends - AbstractTestEastPF { - - @Before - public void init() { - dataset = SpatialSearchUtil.initInMemoryDatasetWithSolrSpatitalIndex(); - } - - @After - public void destroy() { - SpatialIndexSolr index = (SpatialIndexSolr) dataset.getContext().get(SpatialQuery.spatialIndex) ; - index.getServer().shutdown(); - SpatialSearchUtil.deleteOldSolrDataDir(); - } - -} diff --git a/jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/solr/TestIntersectsBoxPFWithEmbeddedSolrSpatialIndex.java b/jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/solr/TestIntersectsBoxPFWithEmbeddedSolrSpatialIndex.java deleted file mode 100644 index 551f0c1fea9..00000000000 --- a/jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/solr/TestIntersectsBoxPFWithEmbeddedSolrSpatialIndex.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.jena.query.spatial.pfunction.solr; - -import org.apache.jena.query.spatial.SpatialIndexSolr; -import org.apache.jena.query.spatial.SpatialQuery; -import org.apache.jena.query.spatial.SpatialSearchUtil; -import org.apache.jena.query.spatial.pfunction.AbstractTestIntersectsBoxPF; -import org.junit.After; -import org.junit.Before; - - -public class TestIntersectsBoxPFWithEmbeddedSolrSpatialIndex extends - AbstractTestIntersectsBoxPF { - - @Before - public void init() { - dataset = SpatialSearchUtil.initInMemoryDatasetWithSolrSpatitalIndex(); - } - - @After - public void destroy() { - SpatialIndexSolr index = (SpatialIndexSolr) dataset.getContext().get(SpatialQuery.spatialIndex) ; - index.getServer().shutdown(); - SpatialSearchUtil.deleteOldSolrDataDir(); - } - -} diff --git a/jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/solr/TestIsNearByPFWithEmbeddedSolrSpatialIndex.java b/jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/solr/TestIsNearByPFWithEmbeddedSolrSpatialIndex.java deleted file mode 100644 index 73e417bf8a9..00000000000 --- a/jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/solr/TestIsNearByPFWithEmbeddedSolrSpatialIndex.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.jena.query.spatial.pfunction.solr; - -import org.apache.jena.query.spatial.SpatialIndexSolr; -import org.apache.jena.query.spatial.SpatialQuery; -import org.apache.jena.query.spatial.SpatialSearchUtil; -import org.apache.jena.query.spatial.pfunction.AbstractTestIsNearByPF; -import org.junit.After; -import org.junit.Before; - -public class TestIsNearByPFWithEmbeddedSolrSpatialIndex extends AbstractTestIsNearByPF { - - @Before - public void init() { - dataset = SpatialSearchUtil.initInMemoryDatasetWithSolrSpatitalIndex(); - } - - @After - public void destroy() { - SpatialIndexSolr index = (SpatialIndexSolr) dataset.getContext().get(SpatialQuery.spatialIndex) ; - index.getServer().shutdown(); - SpatialSearchUtil.deleteOldSolrDataDir(); - } -} diff --git a/jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/solr/TestIsWithinBoxPFWithEmbeddedSolrSpatialIndex.java b/jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/solr/TestIsWithinBoxPFWithEmbeddedSolrSpatialIndex.java deleted file mode 100644 index 46028f5546a..00000000000 --- a/jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/solr/TestIsWithinBoxPFWithEmbeddedSolrSpatialIndex.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.jena.query.spatial.pfunction.solr; - -import org.apache.jena.query.spatial.SpatialIndexSolr; -import org.apache.jena.query.spatial.SpatialQuery; -import org.apache.jena.query.spatial.SpatialSearchUtil; -import org.apache.jena.query.spatial.pfunction.AbstractTestIsWithinBoxPF; -import org.junit.After; -import org.junit.Before; - -/** - * This abstract class defines a setup configuration for a dataset with a Lucene - * index. - */ -public class TestIsWithinBoxPFWithEmbeddedSolrSpatialIndex extends - AbstractTestIsWithinBoxPF { - - @Before - public void init() { - dataset = SpatialSearchUtil.initInMemoryDatasetWithSolrSpatitalIndex(); - } - - @After - public void destroy() { - SpatialIndexSolr index = (SpatialIndexSolr) dataset.getContext().get(SpatialQuery.spatialIndex) ; - index.getServer().shutdown(); - SpatialSearchUtil.deleteOldSolrDataDir(); - } - -} diff --git a/jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/solr/TestIsWithinCirclePFWithEmbeddedSolrSpatialIndex.java b/jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/solr/TestIsWithinCirclePFWithEmbeddedSolrSpatialIndex.java deleted file mode 100644 index 4221af9192f..00000000000 --- a/jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/solr/TestIsWithinCirclePFWithEmbeddedSolrSpatialIndex.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.jena.query.spatial.pfunction.solr; - -import org.apache.jena.query.spatial.SpatialIndexSolr; -import org.apache.jena.query.spatial.SpatialQuery; -import org.apache.jena.query.spatial.SpatialSearchUtil; -import org.apache.jena.query.spatial.pfunction.AbstractTestIsWithinCirclePF; -import org.junit.After; -import org.junit.Before; - -public class TestIsWithinCirclePFWithEmbeddedSolrSpatialIndex extends AbstractTestIsWithinCirclePF { - - @Before - public void init() { - dataset = SpatialSearchUtil.initInMemoryDatasetWithSolrSpatitalIndex(); - } - - @After - public void destroy() { - SpatialIndexSolr index = (SpatialIndexSolr) dataset.getContext().get(SpatialQuery.spatialIndex) ; - index.getServer().shutdown(); - SpatialSearchUtil.deleteOldSolrDataDir(); - } -} diff --git a/jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/solr/TestNorthPFWithEmbeddedSolrSpatialIndex.java b/jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/solr/TestNorthPFWithEmbeddedSolrSpatialIndex.java deleted file mode 100644 index 824231606c6..00000000000 --- a/jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/solr/TestNorthPFWithEmbeddedSolrSpatialIndex.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.jena.query.spatial.pfunction.solr; - -import org.apache.jena.query.spatial.SpatialIndexSolr; -import org.apache.jena.query.spatial.SpatialQuery; -import org.apache.jena.query.spatial.SpatialSearchUtil; -import org.apache.jena.query.spatial.pfunction.AbstractTestNorthPF; -import org.junit.After; -import org.junit.Before; - -/** - * This abstract class defines a setup configuration for a dataset with a Lucene - * index. - */ -public class TestNorthPFWithEmbeddedSolrSpatialIndex extends - AbstractTestNorthPF { - - @Before - public void init() { - dataset = SpatialSearchUtil.initInMemoryDatasetWithSolrSpatitalIndex(); - } - - @After - public void destroy() { - SpatialIndexSolr index = (SpatialIndexSolr) dataset.getContext().get(SpatialQuery.spatialIndex) ; - index.getServer().shutdown(); - SpatialSearchUtil.deleteOldSolrDataDir(); - } - -} diff --git a/jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/solr/TestSouthPFWithEmbeddedSolrSpatialIndex.java b/jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/solr/TestSouthPFWithEmbeddedSolrSpatialIndex.java deleted file mode 100644 index 791f4d007e2..00000000000 --- a/jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/solr/TestSouthPFWithEmbeddedSolrSpatialIndex.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.jena.query.spatial.pfunction.solr; - -import org.apache.jena.query.spatial.SpatialIndexSolr; -import org.apache.jena.query.spatial.SpatialQuery; -import org.apache.jena.query.spatial.SpatialSearchUtil; -import org.apache.jena.query.spatial.pfunction.AbstractTestSouthPF; -import org.junit.After; -import org.junit.Before; - -/** - * This abstract class defines a setup configuration for a dataset with a Lucene - * index. - */ -public class TestSouthPFWithEmbeddedSolrSpatialIndex extends - AbstractTestSouthPF { - - @Before - public void init() { - dataset = SpatialSearchUtil.initInMemoryDatasetWithSolrSpatitalIndex(); - } - - @After - public void destroy() { - SpatialIndexSolr index = (SpatialIndexSolr) dataset.getContext().get(SpatialQuery.spatialIndex) ; - index.getServer().shutdown(); - SpatialSearchUtil.deleteOldSolrDataDir(); - } - -} diff --git a/jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/solr/TestWestPFWithEmbeddedSolrSpatialIndex.java b/jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/solr/TestWestPFWithEmbeddedSolrSpatialIndex.java deleted file mode 100644 index 05f2f88535f..00000000000 --- a/jena-spatial/src/test/java/org/apache/jena/query/spatial/pfunction/solr/TestWestPFWithEmbeddedSolrSpatialIndex.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.jena.query.spatial.pfunction.solr; - -import org.apache.jena.query.spatial.SpatialIndexSolr; -import org.apache.jena.query.spatial.SpatialQuery; -import org.apache.jena.query.spatial.SpatialSearchUtil; -import org.apache.jena.query.spatial.pfunction.AbstractTestWestPF; -import org.junit.After; -import org.junit.Before; - -/** - * This abstract class defines a setup configuration for a dataset with a Lucene - * index. - */ -public class TestWestPFWithEmbeddedSolrSpatialIndex extends - AbstractTestWestPF { - - @Before - public void init() { - dataset = SpatialSearchUtil.initInMemoryDatasetWithSolrSpatitalIndex(); - } - - @After - public void destroy() { - SpatialIndexSolr index = (SpatialIndexSolr) dataset.getContext().get(SpatialQuery.spatialIndex) ; - index.getServer().shutdown(); - SpatialSearchUtil.deleteOldSolrDataDir(); - } - -} diff --git a/jena-spatial/src/test/resources/SolrHome/SolrARQCollection/conf/schema.xml b/jena-spatial/src/test/resources/SolrHome/SolrARQCollection/conf/schema.xml deleted file mode 100644 index c6137a275bb..00000000000 --- a/jena-spatial/src/test/resources/SolrHome/SolrARQCollection/conf/schema.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - uri - - - - - - - - - - - - - diff --git a/jena-spatial/src/test/resources/SolrHome/SolrARQCollection/conf/solrconfig.xml b/jena-spatial/src/test/resources/SolrHome/SolrARQCollection/conf/solrconfig.xml deleted file mode 100644 index 01967fbf91b..00000000000 --- a/jena-spatial/src/test/resources/SolrHome/SolrARQCollection/conf/solrconfig.xml +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - LUCENE_43 - - - - - - - - - - - - - diff --git a/jena-spatial/src/test/resources/SolrHome/solr.xml b/jena-spatial/src/test/resources/SolrHome/solr.xml deleted file mode 100644 index 8d364d944e2..00000000000 --- a/jena-spatial/src/test/resources/SolrHome/solr.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/jena-spatial/src/test/resources/log4j.properties b/jena-spatial/src/test/resources/log4j.properties index ebe69146934..58b8650ec86 100644 --- a/jena-spatial/src/test/resources/log4j.properties +++ b/jena-spatial/src/test/resources/log4j.properties @@ -9,9 +9,4 @@ log4j.appender.stdlog.layout.ConversionPattern=%d{HH:mm:ss} %-5p %-25c{1} :: %m% log4j.logger.org.apache.jena.arq.info=INFO log4j.logger.org.apache.jena.arq.exec=INFO -log4j.logger.org.apache.jena.query.spatial=ERROR - -## Solr can be noisy. -log4j.logger.org.apache.solr=WARN -log4j.logger.org.apache.solr.core.CoreContainer=FATAL -log4j.logger.org.apache.solr.core.JmxMonitoredMap=FATAL +log4j.logger.org.apache.jena.query.spatial=ERROR \ No newline at end of file diff --git a/jena-spatial/src/test/resources/spatial-config-spatialindexer.ttl b/jena-spatial/src/test/resources/spatial-config-spatialindexer.ttl index e1fae4dc74f..c8769756bdf 100644 --- a/jena-spatial/src/test/resources/spatial-config-spatialindexer.ttl +++ b/jena-spatial/src/test/resources/spatial-config-spatialindexer.ttl @@ -10,7 +10,6 @@ # Spatial [] ja:loadClass "org.apache.jena.query.spatial.SpatialQuery" . spatial:SpatialtDataset rdfs:subClassOf ja:RDFDataset . -#spatial:SpatialIndexSolr rdfs:subClassOf spatial:SpatialIndex . spatial:SpatialIndexLucene rdfs:subClassOf spatial:SpatialIndex . ## --------------------------------------------------------------- @@ -18,7 +17,6 @@ spatial:SpatialIndexLucene rdfs:subClassOf spatial:SpatialIndex . :spatial_dataset rdf:type spatial:SpatialDataset ; spatial:dataset <#dataset> ; - ##spaital:index <#indexSolr> ; spatial:index <#indexLucene> ; . diff --git a/jena-spatial/src/test/resources/spatial-config.ttl b/jena-spatial/src/test/resources/spatial-config.ttl index 258c9650af0..861f9002620 100644 --- a/jena-spatial/src/test/resources/spatial-config.ttl +++ b/jena-spatial/src/test/resources/spatial-config.ttl @@ -15,7 +15,6 @@ tdb:GraphTDB rdfs:subClassOf ja:Model . # Spatial [] ja:loadClass "org.apache.jena.query.spatial.SpatialQuery" . spatial:SpatialtDataset rdfs:subClassOf ja:RDFDataset . -#spatial:SpatialIndexSolr rdfs:subClassOf spatial:SpatialIndex . spatial:SpatialIndexLucene rdfs:subClassOf spatial:SpatialIndex . ## --------------------------------------------------------------- @@ -23,7 +22,6 @@ spatial:SpatialIndexLucene rdfs:subClassOf spatial:SpatialIndex . :spatial_dataset rdf:type spatial:SpatialDataset ; spatial:dataset <#dataset> ; - ##spaital:index <#indexSolr> ; spatial:index <#indexLucene> ; . diff --git a/jena-spatial/src/test/resources/spatial-solr-config.ttl b/jena-spatial/src/test/resources/spatial-solr-config.ttl deleted file mode 100644 index b8f16ed9b4a..00000000000 --- a/jena-spatial/src/test/resources/spatial-solr-config.ttl +++ /dev/null @@ -1,51 +0,0 @@ - ## Example of a TDB dataset and spatial index - -@prefix : . -@prefix rdf: . -@prefix rdfs: . -@prefix tdb: . -@prefix ja: . -@prefix spatial: . - -# TDB -[] ja:loadClass "org.apache.jena.tdb.TDB" . -tdb:DatasetTDB rdfs:subClassOf ja:RDFDataset . -tdb:GraphTDB rdfs:subClassOf ja:Model . - -# Spatial -[] ja:loadClass "org.apache.jena.query.spatial.SpatialQuery" . -spatial:SpatialDataset rdfs:subClassOf ja:RDFDataset . -spatial:SpatialIndexSolr rdfs:subClassOf spatial:SpatialIndex . - -## --------------------------------------------------------------- -## This URI must be fixed - it's used to assemble the spatial dataset. - -:spatial_dataset rdf:type spatial:SpatialDataset ; - spatial:dataset <#dataset> ; - spatial:index <#indexSolr> ; - . - -<#dataset> rdf:type tdb:DatasetTDB ; - tdb:location "--mem--" ; - . - -<#indexSolr> a spatial:SpatialIndexSolr ; - spatial:server ; - spatial:solrHome ; - spatial:definition <#definition> ; - . - -<#definition> a spatial:EntityDefinition ; - spatial:entityField "uri" ; - spatial:geoField "geo" ; - # custom geo predicates for 1) latitude/longitude - spatial:hasSpatialPredicatePairs ( - [ spatial:latitude :latitude_1 ; spatial:longitude :longitude_1 ] - [ spatial:latitude :latitude_2 ; spatial:longitude :longitude_2 ] - ) ; - # custom geo predicates for 2) Well Known Text Literal - spatial:hasWKTPredicates (:wkt_1 :wkt_2) ; - # custom SpatialContextFactory for 2) Well Known Text Literal - spatial:spatialContextFactory - "com.spatial4j.core.context.jts.JtsSpatialContextFactory" - . \ No newline at end of file diff --git a/jena-text/pom.xml b/jena-text/pom.xml index c201e61b19a..37010f1eebe 100644 --- a/jena-text/pom.xml +++ b/jena-text/pom.xml @@ -81,40 +81,6 @@ lucene-queryparser - - - solr-solrj - org.apache.solr - - - - diff --git a/jena-text/src/main/java/jena/textindexdump.java b/jena-text/src/main/java/jena/textindexdump.java index 08f6cfb5087..09a258fccd6 100644 --- a/jena-text/src/main/java/jena/textindexdump.java +++ b/jena-text/src/main/java/jena/textindexdump.java @@ -87,14 +87,10 @@ protected void exec() { if ( textIndex instanceof TextIndexLucene ) dump((TextIndexLucene)textIndex) ; - else if ( textIndex instanceof TextIndexSolr ) - dump((TextIndexSolr)textIndex) ; else System.err.println("Unsupported index type : "+Lib.className(textIndex)) ; } - private static void dump(TextIndexSolr textIndex) { System.err.println("Not implemented : dump Solr index") ; } - private static void dump(TextIndexLucene textIndex) { try { Directory directory = textIndex.getDirectory() ; diff --git a/jena-text/src/main/java/org/apache/jena/query/text/TextDatasetFactory.java b/jena-text/src/main/java/org/apache/jena/query/text/TextDatasetFactory.java index 043c4823b1f..c365fa5c8f9 100644 --- a/jena-text/src/main/java/org/apache/jena/query/text/TextDatasetFactory.java +++ b/jena-text/src/main/java/org/apache/jena/query/text/TextDatasetFactory.java @@ -27,7 +27,6 @@ import org.apache.jena.system.JenaSystem ; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.store.Directory ; -import org.apache.solr.client.solrj.SolrServer ; public class TextDatasetFactory { @@ -165,26 +164,5 @@ public static DatasetGraph createLucene(DatasetGraph base, Directory directory, TextIndex index = createLuceneIndex(directory, config) ; return create(base, index, true) ; } - - /** Create a Solr TextIndex */ - public static TextIndex createSolrIndex(SolrServer server, EntityDefinition entMap) - { - TextIndex index = new TextIndexSolr(server, entMap) ; - return index ; - } - - /** Create a text-indexed dataset, using Solr */ - public static Dataset createSolrIndex(Dataset base, SolrServer server, EntityDefinition entMap) - { - TextIndex index = createSolrIndex(server, entMap) ; - return create(base, index, true) ; - } - - /** Create a text-indexed dataset, using Solr */ - public static DatasetGraph createSolrIndex(DatasetGraph base, SolrServer server, EntityDefinition entMap) - { - TextIndex index = createSolrIndex(server, entMap) ; - return create(base, index, true) ; - } } diff --git a/jena-text/src/main/java/org/apache/jena/query/text/TextIndexLucene.java b/jena-text/src/main/java/org/apache/jena/query/text/TextIndexLucene.java index b40ba03f31c..88baf540f4c 100644 --- a/jena-text/src/main/java/org/apache/jena/query/text/TextIndexLucene.java +++ b/jena-text/src/main/java/org/apache/jena/query/text/TextIndexLucene.java @@ -343,7 +343,6 @@ private Query parseQuery(String queryString, Analyzer analyzer) throws ParseExce ScoreDoc[] sDocs = indexSearcher.search(query, 1).scoreDocs ; List> records = new ArrayList<>() ; - // Align and DRY with Solr. for ( ScoreDoc sd : sDocs ) { Document doc = indexSearcher.doc(sd.doc) ; String[] x = doc.getValues(docDef.getEntityField()) ; @@ -393,7 +392,6 @@ public List query(Node property, String qs, int limit) { List results = new ArrayList<>() ; - // Align and DRY with Solr. for ( ScoreDoc sd : sDocs ) { Document doc = indexSearcher.doc(sd.doc) ; String[] values = doc.getValues(docDef.getEntityField()) ; diff --git a/jena-text/src/main/java/org/apache/jena/query/text/TextIndexSolr.java b/jena-text/src/main/java/org/apache/jena/query/text/TextIndexSolr.java deleted file mode 100644 index 2f31955ffd6..00000000000 --- a/jena-text/src/main/java/org/apache/jena/query/text/TextIndexSolr.java +++ /dev/null @@ -1,251 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.jena.query.text; - -import java.io.IOException ; -import java.util.ArrayList ; -import java.util.HashMap ; -import java.util.List ; -import java.util.Map ; -import java.util.Map.Entry ; - -import org.apache.jena.graph.Node ; -import org.apache.jena.graph.NodeFactory ; -import org.apache.jena.sparql.util.NodeFactoryExtra ; -import org.apache.solr.client.solrj.SolrQuery ; -import org.apache.solr.client.solrj.SolrServer ; -import org.apache.solr.client.solrj.SolrServerException ; -import org.apache.solr.client.solrj.response.QueryResponse ; -import org.apache.solr.client.solrj.util.ClientUtils ; -import org.apache.solr.common.SolrDocument ; -import org.apache.solr.common.SolrDocumentList ; -import org.apache.solr.common.SolrInputDocument ; -import org.apache.solr.common.params.CommonParams ; -import org.slf4j.Logger ; -import org.slf4j.LoggerFactory ; - -public class TextIndexSolr implements TextIndex -{ - private static final Logger log = LoggerFactory.getLogger(TextIndexSolr.class) ; - private final SolrServer solrServer ; - private final EntityDefinition docDef ; - private static final int MAX_N = 10000 ; - - public TextIndexSolr(SolrServer server, EntityDefinition def) { - this.solrServer = server ; - this.docDef = def ; - } - - @Override - public void updateEntity(Entity entity) { - throw new RuntimeException("TextIndexSolr.updateEntity not implemented.") ; - } - - @Override - public void prepareCommit() {} - - @Override - public void commit() { - try { - solrServer.commit() ; - } - catch (SolrServerException e) { - throw new TextIndexException(e) ; - } - catch (IOException e) { - throw new TextIndexException(e) ; - } - } - - @Override - public void rollback() { - try { - solrServer.rollback() ; - } - catch (SolrServerException e) { - throw new TextIndexException(e) ; - } - catch (IOException e) { - throw new TextIndexException(e) ; - } - } - - @Override - public void close() { - if ( solrServer != null ) - solrServer.shutdown() ; - } - - @Override - public void addEntity(Entity entity) { - // log.info("Add entity: "+entity) ; - try { - SolrInputDocument doc = solrDoc(entity) ; - solrServer.add(doc) ; - } - catch (Exception e) { - exception(e) ; - } - } - - @Override - public void deleteEntity(Entity entity) { - //to be implemented - } - - private SolrInputDocument solrDoc(Entity entity) - { - SolrInputDocument doc = new SolrInputDocument() ; - doc.addField(docDef.getEntityField(), entity.getId()) ; - - String graphField = docDef.getGraphField() ; - if ( graphField != null ) { - doc.addField(graphField, entity.getGraph()) ; - } - - // the addition needs to be done as a partial update - // otherwise, if we have multiple fields, each successive - // addition will replace the previous one and we are left - // with only the last field indexed. - // see - // http://stackoverflow.com/questions/12183798/solrj-api-for-partial-document-update - // and - // https://svn.apache.org/repos/asf/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java - HashMap map = new HashMap<>() ; - for ( Entry e : entity.getMap().entrySet() ) { - map.put("add", e.getValue()) ; - doc.addField(e.getKey(), map) ; - } - return doc ; - } - - @Override - public Map get(String uri) { - String escaped = ClientUtils.escapeQueryChars(uri) ; - String qs = docDef.getEntityField() + ":" + escaped ; - SolrDocumentList solrResults = solrQuery(qs, 1) ; - - List> records = process(solrResults) ; - if ( records.size() == 0 ) - return null ; - if ( records.size() > 1 ) - log.warn("Multiple docs for one URI: " + uri) ; - return records.get(0) ; - } - - private List> process(SolrDocumentList solrResults) { - List> records = new ArrayList<>() ; - - for ( SolrDocument sd : solrResults ) { - Map record = new HashMap<>() ; - String uriStr = (String)sd.getFieldValue(docDef.getEntityField()) ; - Node entity = NodeFactory.createURI(uriStr) ; - record.put(docDef.getEntityField(), entity) ; - - for ( String f : docDef.fields() ) { - // log.info("Field: "+f) ; - Object obj = sd.getFieldValue(f) ; - // log.info("Value: "+obj) ; - if ( obj == null ) - continue ; - // Multivalued -> array. - // Null means "not stored" or "not present" - if ( obj instanceof List ) - continue ; - - String v = (String)obj ; - Node n = entryToNode(v) ; - record.put(f, n) ; - } - - // log.info("Entity: "+uriStr) ; - records.add(record) ; - } - return records ; - } - - @Override - public List query(Node property, String qs) { return query(property, qs, 0) ; } - - @Override - public List query(Node property, String qs, int limit) { - SolrDocumentList solrResults = solrQuery(qs, limit) ; - List results = new ArrayList<>() ; - - for ( SolrDocument sd : solrResults ) { - String str = (String)sd.getFieldValue(docDef.getEntityField()) ; - // log.info("Entity: "+uriStr) ; - Node n = TextQueryFuncs.stringToNode(str) ; - Float score = (Float) sd.getFirstValue("score"); - // capture literal value, if stored - Node literal = null; - String field = (property != null) ? docDef.getField(property) : docDef.getPrimaryField(); - String value = (String) sd.getFirstValue(field); - if (value != null) { - literal = NodeFactory.createLiteral(value); // FIXME: language and datatype - } - TextHit hit = new TextHit(n, score.floatValue(), literal); - results.add(hit) ; - } - - if ( limit > 0 && results.size() > limit ) - results = results.subList(0, limit) ; - - return results ; - } - - private SolrDocumentList solrQuery(String qs, int limit) { - SolrQuery sq = new SolrQuery(qs) ; - sq.setIncludeScore(true) ; - if ( limit > 0 ) - sq.setRows(limit) ; - else - sq.setRows(MAX_N) ; // The Solr default is 10. - try { - // Set default field. - sq.add(CommonParams.DF, docDef.getPrimaryField()) ; - QueryResponse rsp = solrServer.query(sq) ; - SolrDocumentList docs = rsp.getResults() ; - return docs ; - } - catch (SolrServerException e) { - exception(e) ; - return null ; - } - } - - @Override - public EntityDefinition getDocDef() { - return docDef ; - } - - private Node entryToNode(String v) { - // TEMP - return NodeFactoryExtra.createLiteralNode(v, null, null) ; - } - - public SolrServer getServer() { - return solrServer ; - } - - private static Void exception(Exception ex) { - throw new TextIndexException(ex) ; - } -} - diff --git a/jena-text/src/main/java/org/apache/jena/query/text/TextQueryFuncs.java b/jena-text/src/main/java/org/apache/jena/query/text/TextQueryFuncs.java index 0aa4f38e3f6..695ba69a847 100644 --- a/jena-text/src/main/java/org/apache/jena/query/text/TextQueryFuncs.java +++ b/jena-text/src/main/java/org/apache/jena/query/text/TextQueryFuncs.java @@ -28,7 +28,7 @@ /** Functions relating to text query */ public class TextQueryFuncs { - /** Create a string to put in a Lucene/Solr index for the subject node */ + /** Create a string to put in a Lucene index for the subject node */ public static String subjectToString(Node s) { if ( s == null ) throw new IllegalArgumentException("Subject node can not be null") ; @@ -37,7 +37,7 @@ public static String subjectToString(Node s) { return nodeToString(s) ; } - /** Create a string to put in a Lucene/Solr index for a graph node */ + /** Create a string to put in a Lucene index for a graph node */ public static String graphNodeToString(Node g) { if ( g == null ) return null ; @@ -50,7 +50,7 @@ private static String nodeToString(Node n) { return (n.isURI() ) ? n.getURI() : "_:" + n.getBlankNodeLabel() ; } - /** Recover a Node from a stored Lucene/Solr string */ + /** Recover a Node from a stored Lucene string */ public static Node stringToNode(String v) { if ( v.startsWith("_:") ) { v = v.substring("_:".length()) ; diff --git a/jena-text/src/main/java/org/apache/jena/query/text/TextQueryPF.java b/jena-text/src/main/java/org/apache/jena/query/text/TextQueryPF.java index 323ffe1c7d5..6c67e9104ab 100644 --- a/jena-text/src/main/java/org/apache/jena/query/text/TextQueryPF.java +++ b/jena-text/src/main/java/org/apache/jena/query/text/TextQueryPF.java @@ -53,7 +53,7 @@ import org.slf4j.Logger ; import org.slf4j.LoggerFactory ; -/** property function that accesses a Solr server */ +/** property function that accesses a text index */ public class TextQueryPF extends PropertyFunctionBase { private static Logger log = LoggerFactory.getLogger(TextQueryPF.class) ; /* diff --git a/jena-text/src/main/java/org/apache/jena/query/text/assembler/TextAssembler.java b/jena-text/src/main/java/org/apache/jena/query/text/assembler/TextAssembler.java index c6c61542664..a14f8c675ef 100644 --- a/jena-text/src/main/java/org/apache/jena/query/text/assembler/TextAssembler.java +++ b/jena-text/src/main/java/org/apache/jena/query/text/assembler/TextAssembler.java @@ -29,7 +29,6 @@ public static void init() AssemblerUtils.registerDataset(TextVocab.textDataset, new TextDatasetAssembler()) ; Assembler.general.implementWith(TextVocab.entityMap, new EntityDefinitionAssembler()) ; - Assembler.general.implementWith(TextVocab.textIndexSolr, new TextIndexSolrAssembler()) ; Assembler.general.implementWith(TextVocab.textIndexLucene, new TextIndexLuceneAssembler()) ; Assembler.general.implementWith(TextVocab.standardAnalyzer, new StandardAnalyzerAssembler()) ; Assembler.general.implementWith(TextVocab.simpleAnalyzer, new SimpleAnalyzerAssembler()) ; diff --git a/jena-text/src/main/java/org/apache/jena/query/text/assembler/TextIndexSolrAssembler.java b/jena-text/src/main/java/org/apache/jena/query/text/assembler/TextIndexSolrAssembler.java deleted file mode 100644 index 2e174bdbbd7..00000000000 --- a/jena-text/src/main/java/org/apache/jena/query/text/assembler/TextIndexSolrAssembler.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.jena.query.text.assembler; - -import static org.apache.jena.query.text.assembler.TextVocab.pEntityMap ; -import static org.apache.jena.query.text.assembler.TextVocab.pServer ; -import org.apache.jena.assembler.Assembler ; -import org.apache.jena.assembler.Mode ; -import org.apache.jena.assembler.assemblers.AssemblerBase ; -import org.apache.jena.query.text.EntityDefinition ; -import org.apache.jena.query.text.TextDatasetFactory ; -import org.apache.jena.query.text.TextIndex ; -import org.apache.jena.query.text.TextIndexException ; -import org.apache.jena.rdf.model.Resource ; -import org.apache.jena.sparql.util.graph.GraphUtils ; -import org.apache.solr.client.solrj.SolrServer ; -import org.apache.solr.client.solrj.impl.HttpSolrServer ; - -public class TextIndexSolrAssembler extends AssemblerBase -{ - /* - <#index> a :TextIndexSolr ; - text:server ; - #text:server ; - text:entityMap <#endMap> ; - . - */ - - @Override - public TextIndex open(Assembler a, Resource root, Mode mode) { - String uri = GraphUtils.getResourceValue(root, pServer).getURI() ; - SolrServer server ; - if ( uri.startsWith("embedded:") ) { - throw new TextIndexException("Embedded Solr server not supported (change code and dependencies to enable)") ; -// String coreName = uri.substring("embedded:".length()) ; -// CoreContainer.Initializer initializer = new CoreContainer.Initializer(); -// CoreContainer coreContainer ; -// try { coreContainer = initializer.initialize() ; } -// catch (Exception e) { throw new TextIndexException("Filed to initialize embedded solr", e) ; } -// server = new EmbeddedSolrServer(coreContainer, coreName); - } - else if ( uri.startsWith("http://") ) - server = new HttpSolrServer( uri ); - else - throw new TextIndexException("URI for the server must begin 'http://'") ; - - Resource r = GraphUtils.getResourceValue(root, pEntityMap) ; - EntityDefinition docDef = (EntityDefinition)a.open(r) ; - return TextDatasetFactory.createSolrIndex(server, docDef) ; - } -} - diff --git a/jena-text/src/main/java/org/apache/jena/query/text/assembler/TextVocab.java b/jena-text/src/main/java/org/apache/jena/query/text/assembler/TextVocab.java index d60aafbf00f..582f2ef138f 100644 --- a/jena-text/src/main/java/org/apache/jena/query/text/assembler/TextVocab.java +++ b/jena-text/src/main/java/org/apache/jena/query/text/assembler/TextVocab.java @@ -34,10 +34,8 @@ public class TextVocab public static final Property pTextDocProducer = Vocab.property(NS, "textDocProducer") ; public static final Resource textIndex = Vocab.resource(NS, "TextIndex") ; - public static final Resource textIndexSolr = Vocab.resource(NS, "TextIndexSolr") ; public static final Resource textIndexLucene = Vocab.resource(NS, "TextIndexLucene") ; public static final Property pLanguage = Vocab.property(NS, "language") ; - public static final Property pServer = Vocab.property(NS, "server") ; // Solr public static final Property pDirectory = Vocab.property(NS, "directory") ; // Lucene public static final Property pMultilingualSupport = Vocab.property(NS, "multilingualSupport") ; public static final Property pStoreValues = Vocab.property(NS, "storeValues") ; diff --git a/jena-text/src/test/java/org/apache/jena/query/text/TS_Text.java b/jena-text/src/test/java/org/apache/jena/query/text/TS_Text.java index beff77bae1a..4cb6c21f9bf 100644 --- a/jena-text/src/test/java/org/apache/jena/query/text/TS_Text.java +++ b/jena-text/src/test/java/org/apache/jena/query/text/TS_Text.java @@ -21,7 +21,6 @@ import org.apache.jena.query.text.assembler.TestEntityMapAssembler ; import org.apache.jena.query.text.assembler.TestTextDatasetAssembler ; import org.apache.jena.query.text.assembler.TestTextIndexLuceneAssembler ; -import org.apache.jena.query.text.assembler.TestTextIndexSolrAssembler ; import org.junit.runner.RunWith ; import org.junit.runners.Suite ; import org.junit.runners.Suite.SuiteClasses ; @@ -35,14 +34,9 @@ , TestDatasetWithLuceneGraphTextIndex.class , TestDatasetWithLuceneTextIndexDeletionSupport.class , TestDatasetWithLuceneStoredLiterals.class - - // Embedded solr not supported - //, TestDatasetWithEmbeddedSolrTextIndex.class - , TestEntityMapAssembler.class , TestTextDatasetAssembler.class , TestTextIndexLuceneAssembler.class - , TestTextIndexSolrAssembler.class , TestTextTDB.class , TestDatasetWithSimpleAnalyzer.class , TestDatasetWithStandardAnalyzer.class diff --git a/jena-text/src/test/java/org/apache/jena/query/text/TestDatasetWithEmbeddedSolrTextIndex.java b/jena-text/src/test/java/org/apache/jena/query/text/TestDatasetWithEmbeddedSolrTextIndex.java deleted file mode 100644 index b33b2009266..00000000000 --- a/jena-text/src/test/java/org/apache/jena/query/text/TestDatasetWithEmbeddedSolrTextIndex.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.jena.query.text; - -import java.io.File ; - -import org.junit.After ; -import org.junit.Before ; - -public class TestDatasetWithEmbeddedSolrTextIndex extends AbstractTestDatasetWithTextIndex { - - private static final String DATA_PATH = "target/test/SolrARQ/data"; - private static final File DATA_DIR = new File(DATA_PATH); - private static final String INDEX_PATH = DATA_PATH + "/index"; - private static final File INDEX_DIR = new File(INDEX_PATH); - private static final String TEST_ASSEM = "testing/TextQuery/text-solr-config.ttl" ; - - @Before - public void before() { - //deleteOldFiles(); - INDEX_DIR.mkdirs(); - TextSearchUtil.createEmptyIndex(INDEX_DIR); - dataset = TextDatasetFactory.create(TEST_ASSEM) ; - } - - @After - public void after() { - TextIndexSolr index = (TextIndexSolr) dataset.getContext().get(TextQuery.textIndex) ; - index.getServer().shutdown(); - deleteOldFiles(); - } - - public void deleteOldFiles() { - dataset.close(); - if (DATA_DIR.exists()) - TextSearchUtil.emptyAndDeleteDirectory(DATA_DIR); - } -} diff --git a/jena-text/src/test/java/org/apache/jena/query/text/assembler/TestTextIndexSolrAssembler.java b/jena-text/src/test/java/org/apache/jena/query/text/assembler/TestTextIndexSolrAssembler.java deleted file mode 100644 index 3e2cb689107..00000000000 --- a/jena-text/src/test/java/org/apache/jena/query/text/assembler/TestTextIndexSolrAssembler.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.jena.query.text.assembler; - -import static org.junit.Assert.assertEquals ; -import static org.junit.Assert.assertTrue ; -import org.apache.jena.assembler.Assembler ; -import org.apache.jena.query.text.TextIndexSolr ; -import org.apache.jena.rdf.model.Resource ; -import org.apache.jena.vocabulary.RDF ; -import org.apache.jena.vocabulary.RDFS ; -import org.apache.solr.client.solrj.impl.HttpSolrServer ; -import org.junit.Test ; - -public class TestTextIndexSolrAssembler extends AbstractTestTextAssembler { - - private static final String TESTBASE = "http://example.org/solrAssembler/"; - private static final Resource EMBEDDED_SOLR_INDEX_SPEC; - private static final Resource HTTP_SOLR_INDEX_SPEC; - -// @Test public void testIndexUsesEmbeddedServer() throws IOException { -// if (EMBEDDED_SOLR.DATA_DIR.exists()) -// TextSearchUtil.emptyAndDeleteDirectory(EMBEDDED_SOLR.DATA_DIR); -// EMBEDDED_SOLR.INDEX_DIR.mkdirs(); -// TextSearchUtil.createEmptyIndex(EMBEDDED_SOLR.INDEX_DIR); -// TextIndexSolr indexSolr = (TextIndexSolr) Assembler.general.open(EMBEDDED_SOLR_INDEX_SPEC); -// assertEquals("org.apache.solr.client.solrj.embedded.EmbeddedSolrServer", indexSolr.getServer().getClass().getName()); -// assertEquals(RDFS.label.asNode(), indexSolr.getDocDef().getPrimaryPredicate()); -// indexSolr.getServer().shutdown(); -// } - - @Test public void testIndexUsesHttpServer() { - TextIndexSolr indexSolr = (TextIndexSolr) Assembler.general.open(HTTP_SOLR_INDEX_SPEC); - assertTrue(indexSolr.getServer() instanceof HttpSolrServer); - assertEquals(indexSolr.getDocDef().getPrimaryPredicate(), RDFS.label.asNode()); - indexSolr.getServer().shutdown(); - } - - static { - TextAssembler.init(); - EMBEDDED_SOLR_INDEX_SPEC = - model.createResource(TESTBASE + "embeddedSolrIndexSpec") - .addProperty(RDF.type, TextVocab.textIndexSolr) - .addProperty(TextVocab.pServer, model.createResource("embedded:solr")) - .addProperty(TextVocab.pEntityMap, SIMPLE_ENTITY_MAP_SPEC); - HTTP_SOLR_INDEX_SPEC = - model.createResource(TESTBASE + "httpSolrIndexSpec") - .addProperty(RDF.type, TextVocab.textIndexSolr) - .addProperty(TextVocab.pServer, model.createResource("http://example.org/solr/index")) - .addProperty(TextVocab.pEntityMap, SIMPLE_ENTITY_MAP_SPEC); - } - -} diff --git a/jena-text/src/test/resources/log4j.properties b/jena-text/src/test/resources/log4j.properties index 9633e15637f..cf96ece1caa 100644 --- a/jena-text/src/test/resources/log4j.properties +++ b/jena-text/src/test/resources/log4j.properties @@ -8,8 +8,3 @@ log4j.appender.stdlog.layout.ConversionPattern=%d{HH:mm:ss} %-5p %-25c{1} :: %m% # Execution logging log4j.logger.org.apache.jena.arq.info=INFO log4j.logger.org.apache.jena.arq.exec=INFO - -## Solr can be noisy. -log4j.logger.org.apache.solr=WARN -log4j.logger.org.apache.solr.core.CoreContainer=FATAL -log4j.logger.org.apache.solr.core.JmxMonitoredMap=FATAL diff --git a/jena-text/testing/TextQuery/text-config-union.ttl b/jena-text/testing/TextQuery/text-config-union.ttl index d0d41b9430b..9c6d16e6bfc 100644 --- a/jena-text/testing/TextQuery/text-config-union.ttl +++ b/jena-text/testing/TextQuery/text-config-union.ttl @@ -15,7 +15,6 @@ tdb:GraphTDB rdfs:subClassOf ja:Model . # Text [] ja:loadClass "org.apache.jena.query.text.TextQuery" . text:TextDataset rdfs:subClassOf ja:RDFDataset . -#text:TextIndexSolr rdfs:subClassOf text:TextIndex . text:TextIndexLucene rdfs:subClassOf text:TextIndex . ## --------------------------------------------------------------- @@ -23,7 +22,6 @@ text:TextIndexLucene rdfs:subClassOf text:TextIndex . :text_dataset rdf:type text:TextDataset ; text:dataset <#dataset> ; - ##text:index <#indexSolr> ; text:index <#indexLucene> ; . diff --git a/jena-text/testing/TextQuery/text-config.ttl b/jena-text/testing/TextQuery/text-config.ttl index 8c4d4d5aafa..fb446de95e1 100644 --- a/jena-text/testing/TextQuery/text-config.ttl +++ b/jena-text/testing/TextQuery/text-config.ttl @@ -15,7 +15,6 @@ tdb:GraphTDB rdfs:subClassOf ja:Model . # Text [] ja:loadClass "org.apache.jena.query.text.TextQuery" . text:TextDataset rdfs:subClassOf ja:RDFDataset . -#text:TextIndexSolr rdfs:subClassOf text:TextIndex . text:TextIndexLucene rdfs:subClassOf text:TextIndex . ## --------------------------------------------------------------- @@ -23,7 +22,6 @@ text:TextIndexLucene rdfs:subClassOf text:TextIndex . :text_dataset rdf:type text:TextDataset ; text:dataset <#dataset> ; - ##text:index <#indexSolr> ; text:index <#indexLucene> ; . diff --git a/jena-text/testing/TextQuery/text-solr-config.ttl b/jena-text/testing/TextQuery/text-solr-config.ttl deleted file mode 100644 index cfd2735a38e..00000000000 --- a/jena-text/testing/TextQuery/text-solr-config.ttl +++ /dev/null @@ -1,45 +0,0 @@ - ## Example of a TDB dataset and text index - -@prefix : . -@prefix rdf: . -@prefix rdfs: . -@prefix tdb: . -@prefix ja: . -@prefix text: . - -# TDB -[] ja:loadClass "org.apache.jena.tdb.TDB" . -tdb:DatasetTDB rdfs:subClassOf ja:RDFDataset . -tdb:GraphTDB rdfs:subClassOf ja:Model . - -# Text -[] ja:loadClass "org.apache.jena.query.text.TextQuery" . -text:TextDataset rdfs:subClassOf ja:RDFDataset . -text:TextIndexSolr rdfs:subClassOf text:TextIndex . - -## --------------------------------------------------------------- -## This URI must be fixed - it's used to assemble the text dataset. - -:text_dataset rdf:type text:TextDataset ; - text:dataset <#dataset> ; - ##text:index <#indexSolr> ; - text:index <#indexLucene> ; - . - -<#dataset> rdf:type tdb:DatasetTDB ; - tdb:location "--mem--" ; - . - -<#indexLucene> a text:TextIndexSolr ; - text:server ; - text:entityMap <#entMap> ; - . - -<#entMap> a text:EntityMap ; - text:entityField "uri" ; - text:defaultField "label" ; ## Must be defined in the text:maps - text:map ( - # rdfs:label - [ text:field "label" ; text:predicate rdfs:label ] - [ text:field "comment" ; text:predicate rdfs:comment ] - ) . diff --git a/jena-text/text-config.ttl b/jena-text/text-config.ttl index 68d58eafb82..878df555281 100644 --- a/jena-text/text-config.ttl +++ b/jena-text/text-config.ttl @@ -31,7 +31,6 @@ tdb:GraphTDB rdfs:subClassOf ja:Model . # Text [] ja:loadClass "org.apache.jena.query.text.TextQuery" . text:TextDataset rdfs:subClassOf ja:RDFDataset . -#text:TextIndexSolr rdfs:subClassOf text:TextIndex . text:TextIndexLucene rdfs:subClassOf text:TextIndex . ## --------------------------------------------------------------- @@ -39,7 +38,6 @@ text:TextIndexLucene rdfs:subClassOf text:TextIndex . :text_dataset rdf:type text:TextDataset ; text:dataset <#dataset> ; - ##text:index <#indexSolr> ; text:index <#indexLucene> ; .