[jira] [Commented] (JENA-647) SPARQL template queries
[ https://issues.apache.org/jira/browse/JENA-647?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15933402#comment-15933402 ] A. Soroka commented on JENA-647: [~buddhiayesha2013] have you had a chance to send that email, or have I missed it? > SPARQL template queries > --- > > Key: JENA-647 > URL: https://issues.apache.org/jira/browse/JENA-647 > Project: Apache Jena > Issue Type: Improvement > Components: Fuseki >Reporter: Andy Seaborne > Labels: gsoc, gsoc2015, gsoc2017, java, web > > This enhancement would added predefined query templates to Fuseki. A query > could be executed by calling the URL of the template together with any > template parameters. It would an HTTP URL that could be bookmarked or passed > around. Coupled with the ability to set the result format, it makes getting > CSV or JSON > See also a related project in JENA-632. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
Re: Bug in SortedDataBag?
On 17 March 2017 at 17:08, Andy Seaborne wrote: > > SortedDataBag.cancel does not call close. > You're quite right, am having another look at the problem. Chris
[jira] [Commented] (JENA-1303) Starting 0 in XSDnonNegativeInteger is badly interpreted
[ https://issues.apache.org/jira/browse/JENA-1303?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15932782#comment-15932782 ] Rob Vesse commented on JENA-1303: - http://jena.apache.org/documentation/tdb/value_canonicalization.html > Starting 0 in XSDnonNegativeInteger is badly interpreted > > > Key: JENA-1303 > URL: https://issues.apache.org/jira/browse/JENA-1303 > Project: Apache Jena > Issue Type: Bug >Affects Versions: Jena 3.1.0, Jena 3.1.1, Jena 3.2.0 >Reporter: Gilles Habran >Assignee: Andy Seaborne > > Hello, > we are currently using Jena 2.7.2 and we need to upgrade to Jena 3.1.0. We > cannot use 3.1.1+ because Oracle Jena Adapter does not support other version > than 3.1.0. > Here is a test to show the problem. > Jena 2.7.2 returns true and Jena 3.1.0 returns false > {code}Model model1 = ModelFactory.createDefaultModel(); > model1.add(model1.createResource("http://jena.apache.org/test";), > model1.createProperty("http://jena.apache.org/size";), > model1.createTypedLiteral("05", XSDDatatype.XSDnonNegativeInteger)); > Model model2 = ModelFactory.createDefaultModel(); > model2.add(model2.createResource("http://jena.apache.org/test";), > model2.createProperty("http://jena.apache.org/size";), > model2.createTypedLiteral("5", XSDDatatype.XSDnonNegativeInteger)); > Assert.assertTrue(model1.isIsomorphicWith(model2));{code} -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Comment Edited] (JENA-1303) Starting 0 in XSDnonNegativeInteger is badly interpreted
[ https://issues.apache.org/jira/browse/JENA-1303?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15932753#comment-15932753 ] Sergey Malinin edited comment on JENA-1303 at 3/20/17 2:52 PM: --- Ok, how you could explain the next behavior, the output for same inserted data is different for TDB Model and Jena InMemory model ? Where is the bug in Jena TDB Storage or in Jena InMemory storage ? Example: {code} Node ns = NodeFactory.createURI("a1"); Node np1 = NodeFactory.createURI("b1"); Node np2 = NodeFactory.createURI("b2"); RDFDatatype dt1 = TypeMapper.getInstance().getSafeTypeByName("http://www.w3.org/2001/XMLSchema#positiveInteger";); Node o1 = NodeFactory.createLiteral("0241", null, dt1); RDFDatatype dt2 = TypeMapper.getInstance().getSafeTypeByName("http://www.w3.org/2001/XMLSchema#dateTime";); Node o2 = NodeFactory.createLiteral("2017-03-14T13:21:40.1700+01:00", null, dt2); String directory = "Dataset1" ; Dataset dataset = TDBFactory.createDataset(directory) ; dataset.begin(ReadWrite.WRITE) ; Model tm = dataset.getDefaultModel() ; Graph tg = tm.getGraph(); tg.add(new Triple(ns, np1, o1)); tg.add(new Triple(ns, np2, o2)); System.out.println("--Jena TDB "); StmtIterator rs = tm.listStatements(); while (rs.hasNext()) { System.out.println(rs.next().toString()); } Model md = ModelFactory.createDefaultModel(); Graph g = md.getGraph(); g.add(new Triple(ns, np1, o1)); g.add(new Triple(ns, np2, o2)); System.out.println("--Jena Memory "); rs = md.listStatements(); while (rs.hasNext()) { System.out.println(rs.next().toString()); } System.out.println("\nisIsomorphicWith = "+md.isIsomorphicWith(tm)); dataset.end() ; dataset.close(); {code} Output log {code} --Jena TDB [a1, b1, "241"^^http://www.w3.org/2001/XMLSchema#integer] [a1, b2, "2017-03-14T13:21:40.17+01:00"^^http://www.w3.org/2001/XMLSchema#dateTime] --Jena Memory [a1, b2, "2017-03-14T13:21:40.1700+01:00"^^http://www.w3.org/2001/XMLSchema#dateTime] [a1, b1, "0241"^^http://www.w3.org/2001/XMLSchema#positiveInteger] isIsomorphicWith = false {code} was (Author: smalinin): Ok, how you could explain the next behavior, the output for same inserted data is different for TDB Model and Jena InMemory model ? Example: {code} Node ns = NodeFactory.createURI("a1"); Node np1 = NodeFactory.createURI("b1"); Node np2 = NodeFactory.createURI("b2"); RDFDatatype dt1 = TypeMapper.getInstance().getSafeTypeByName("http://www.w3.org/2001/XMLSchema#positiveInteger";); Node o1 = NodeFactory.createLiteral("0241", null, dt1); RDFDatatype dt2 = TypeMapper.getInstance().getSafeTypeByName("http://www.w3.org/2001/XMLSchema#dateTime";); Node o2 = NodeFactory.createLiteral("2017-03-14T13:21:40.1700+01:00", null, dt2); String directory = "Dataset1" ; Dataset dataset = TDBFactory.createDataset(directory) ; dataset.begin(ReadWrite.WRITE) ; Model tm = dataset.getDefaultModel() ; Graph tg = tm.getGraph(); tg.add(new Triple(ns, np1, o1)); tg.add(new Triple(ns, np2, o2)); System.out.println("--Jena TDB "); StmtIterator rs = tm.listStatements(); while (rs.hasNext()) { System.out.println(rs.next().toString()); } Model md = ModelFactory.createDefaultModel(); Graph g = md.getGraph(); g.add(new Triple(ns, np1, o1)); g.add(new Triple(ns, np2, o2)); System.out.println("--Jena Memory "); rs = md.listStatements(); while (rs.hasNext()) { System.out.println(rs.next().toString()); } System.out.println("\nisIsomorphicWith = "+md.isIsomorphicWith(tm)); dataset.end() ; dataset.close(); {code} Output log {code} --Jena TDB [a1, b1, "241"^^http://www.w3.org/2001/XMLSchema#integer] [a1, b2, "2017-03-14T13:21:40.17+01:00"^^http://www.w3.org/2001/XMLSchema#dateTime] --Jena Memory [a1, b2, "2017-03-14T13:21:40.1700+01:00"^^http://www.w3.org/2001/XMLSchema#dateTime] [a1, b1, "0241"^^http://www.w3.org/2001/XMLSchema#positiveInteger] isIsomorphicWith = false {code} > Starting 0 in XSDnonNegativeInteger is badly interpreted > > > Key: JENA-1303 > URL: https://issues.apache.org/jira/browse/JENA-1303 > Project: Apache Jena > Issue Type: Bug >Affects Versions: Jena 3.1.0, Jena 3.1.1, Jena 3.2.0 >Reporter: Gill
[jira] [Commented] (JENA-1303) Starting 0 in XSDnonNegativeInteger is badly interpreted
[ https://issues.apache.org/jira/browse/JENA-1303?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15932753#comment-15932753 ] Sergey Malinin commented on JENA-1303: -- Ok, how you could explain the next behavior, the output for same inserted data is different for TDB Model and Jena InMemory model ? Example: {code} Node ns = NodeFactory.createURI("a1"); Node np1 = NodeFactory.createURI("b1"); Node np2 = NodeFactory.createURI("b2"); RDFDatatype dt1 = TypeMapper.getInstance().getSafeTypeByName("http://www.w3.org/2001/XMLSchema#positiveInteger";); Node o1 = NodeFactory.createLiteral("0241", null, dt1); RDFDatatype dt2 = TypeMapper.getInstance().getSafeTypeByName("http://www.w3.org/2001/XMLSchema#dateTime";); Node o2 = NodeFactory.createLiteral("2017-03-14T13:21:40.1700+01:00", null, dt2); String directory = "Dataset1" ; Dataset dataset = TDBFactory.createDataset(directory) ; dataset.begin(ReadWrite.WRITE) ; Model tm = dataset.getDefaultModel() ; Graph tg = tm.getGraph(); tg.add(new Triple(ns, np1, o1)); tg.add(new Triple(ns, np2, o2)); System.out.println("--Jena TDB "); StmtIterator rs = tm.listStatements(); while (rs.hasNext()) { System.out.println(rs.next().toString()); } Model md = ModelFactory.createDefaultModel(); Graph g = md.getGraph(); g.add(new Triple(ns, np1, o1)); g.add(new Triple(ns, np2, o2)); System.out.println("--Jena Memory "); rs = md.listStatements(); while (rs.hasNext()) { System.out.println(rs.next().toString()); } System.out.println("\nisIsomorphicWith = "+md.isIsomorphicWith(tm)); dataset.end() ; dataset.close(); {code} Output log {code} --Jena TDB [a1, b1, "241"^^http://www.w3.org/2001/XMLSchema#integer] [a1, b2, "2017-03-14T13:21:40.17+01:00"^^http://www.w3.org/2001/XMLSchema#dateTime] --Jena Memory [a1, b2, "2017-03-14T13:21:40.1700+01:00"^^http://www.w3.org/2001/XMLSchema#dateTime] [a1, b1, "0241"^^http://www.w3.org/2001/XMLSchema#positiveInteger] isIsomorphicWith = false {code} > Starting 0 in XSDnonNegativeInteger is badly interpreted > > > Key: JENA-1303 > URL: https://issues.apache.org/jira/browse/JENA-1303 > Project: Apache Jena > Issue Type: Bug >Affects Versions: Jena 3.1.0, Jena 3.1.1, Jena 3.2.0 >Reporter: Gilles Habran >Assignee: Andy Seaborne > > Hello, > we are currently using Jena 2.7.2 and we need to upgrade to Jena 3.1.0. We > cannot use 3.1.1+ because Oracle Jena Adapter does not support other version > than 3.1.0. > Here is a test to show the problem. > Jena 2.7.2 returns true and Jena 3.1.0 returns false > {code}Model model1 = ModelFactory.createDefaultModel(); > model1.add(model1.createResource("http://jena.apache.org/test";), > model1.createProperty("http://jena.apache.org/size";), > model1.createTypedLiteral("05", XSDDatatype.XSDnonNegativeInteger)); > Model model2 = ModelFactory.createDefaultModel(); > model2.add(model2.createResource("http://jena.apache.org/test";), > model2.createProperty("http://jena.apache.org/size";), > model2.createTypedLiteral("5", XSDDatatype.XSDnonNegativeInteger)); > Assert.assertTrue(model1.isIsomorphicWith(model2));{code} -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (JENA-632) Generate JSON from SPARQL directly.
[ https://issues.apache.org/jira/browse/JENA-632?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15932533#comment-15932533 ] ASF GitHub Bot commented on JENA-632: - Github user ajs6f commented on the issue: https://github.com/apache/jena/pull/114 No prob-- good to see you back, @kinow ! > Generate JSON from SPARQL directly. > --- > > Key: JENA-632 > URL: https://issues.apache.org/jira/browse/JENA-632 > Project: Apache Jena > Issue Type: Improvement > Components: ARQ, Fuseki >Reporter: Andy Seaborne >Assignee: Bruno P. Kinoshita >Priority: Minor > Labels: java, javacc > Time Spent: 0.5h > Remaining Estimate: 0h > > The capability to generate JSON directly from a SPARQL (or extended SPARQL) > query would enable the creation of JSON data API over published linked data. > This project would cover: > # Design and publication of a design. > # Refinement of design based on community feed > # Implementation, including testing. > # Refinement of implementation based on community feed > Skills required: Java, some parser work, design and discussion with the user > community, basic understanding of HTTP and content negotiation. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[GitHub] jena issue #114: JENA-632: Generate JSON from SPARQL directly
Github user ajs6f commented on the issue: https://github.com/apache/jena/pull/114 No prob-- good to see you back, @kinow ! --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[jira] [Commented] (JENA-632) Generate JSON from SPARQL directly.
[ https://issues.apache.org/jira/browse/JENA-632?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15932483#comment-15932483 ] ASF GitHub Bot commented on JENA-632: - Github user kinow commented on the issue: https://github.com/apache/jena/pull/114 @ajs6f sorry for the delay. Checked out the branch, just need to refresh my memory. Will need a few more days before pinging you guys to check out this PR again. Next month finally will have some time to play with Jena again, then plan to have this PR completed, and check if there's any Fuseki or easy tasks in JIRA :-) Cheers Bruno > Generate JSON from SPARQL directly. > --- > > Key: JENA-632 > URL: https://issues.apache.org/jira/browse/JENA-632 > Project: Apache Jena > Issue Type: Improvement > Components: ARQ, Fuseki >Reporter: Andy Seaborne >Assignee: Bruno P. Kinoshita >Priority: Minor > Labels: java, javacc > Time Spent: 0.5h > Remaining Estimate: 0h > > The capability to generate JSON directly from a SPARQL (or extended SPARQL) > query would enable the creation of JSON data API over published linked data. > This project would cover: > # Design and publication of a design. > # Refinement of design based on community feed > # Implementation, including testing. > # Refinement of implementation based on community feed > Skills required: Java, some parser work, design and discussion with the user > community, basic understanding of HTTP and content negotiation. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[GitHub] jena issue #114: JENA-632: Generate JSON from SPARQL directly
Github user kinow commented on the issue: https://github.com/apache/jena/pull/114 @ajs6f sorry for the delay. Checked out the branch, just need to refresh my memory. Will need a few more days before pinging you guys to check out this PR again. Next month finally will have some time to play with Jena again, then plan to have this PR completed, and check if there's any Fuseki or easy tasks in JIRA :-) Cheers Bruno --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[jira] [Commented] (JENA-1305) Elastic Search Support for Apache Jena Text
[ https://issues.apache.org/jira/browse/JENA-1305?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15932471#comment-15932471 ] ASF GitHub Bot commented on JENA-1305: -- Github user anujgandharv commented on a diff in the pull request: https://github.com/apache/jena/pull/227#discussion_r106870357 --- Diff: jena-text/src/main/java/org/apache/jena/query/text/TextIndexES.java --- @@ -0,0 +1,394 @@ +/** + * 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.graph.Node; +import org.apache.jena.graph.NodeFactory; +import org.apache.jena.sparql.util.NodeFactoryExtra; +import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest; +import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse; +import org.elasticsearch.action.get.GetResponse; +import org.elasticsearch.action.index.IndexRequest; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.action.update.UpdateRequest; +import org.elasticsearch.action.update.UpdateResponse; +import org.elasticsearch.client.Client; +import org.elasticsearch.client.transport.TransportClient; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.transport.InetSocketTransportAddress; +import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.script.Script; +import org.elasticsearch.search.SearchHit; +import org.elasticsearch.transport.client.PreBuiltTransportClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.net.InetAddress; +import java.util.*; + +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; + +/** + * Elastic Search Implementation of {@link TextIndex} + * + */ +public class TextIndexES implements TextIndex { + +/** + * The definition of the Entity we are trying to Index + */ +private final EntityDefinition docDef ; + +/** + * Thread safe ElasticSearch Java Client to perform Index operations + */ +private static Client client; + +/** + * The name of the index. Defaults to 'test' + */ +private final String indexName; + +static final String CLUSTER_NAME_PARAM = "cluster.name"; + +static final String NUM_OF_SHARDS_PARAM = "number_of_shards"; + +static final String NUM_OF_REPLICAS_PARAM = "number_of_replicas"; + +/** + * Number of maximum results to return in case no limit is specified on the search operation + */ +static final Integer MAX_RESULTS = 1; + +private boolean isMultilingual ; + +private static final Logger LOGGER = LoggerFactory.getLogger(TextIndexES.class) ; + +public TextIndexES(TextIndexConfig config, ESSettings esSettings) { + +this.indexName = esSettings.getIndexName(); +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"); +} +try { +if(client == null) { + +LOGGER.debug("Initializing the Elastic Search Java Client with settings: " + esSettings); +Settings settings = Settings.builder() +.put(CLUSTER_NAME_PARAM, esSettings.getClusterName()).build(); +List addresses = new ArrayList<>(); +for(String host: esSettings.getHostToPortMapping().keySet()) { +InetSocketTransportAddress addr = new InetSocketTransportAddress(InetAddress.getByNa
[GitHub] jena pull request #227: JENA-1305 | Elastic search support for Jena Text
Github user anujgandharv commented on a diff in the pull request: https://github.com/apache/jena/pull/227#discussion_r106870357 --- Diff: jena-text/src/main/java/org/apache/jena/query/text/TextIndexES.java --- @@ -0,0 +1,394 @@ +/** + * 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.graph.Node; +import org.apache.jena.graph.NodeFactory; +import org.apache.jena.sparql.util.NodeFactoryExtra; +import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest; +import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse; +import org.elasticsearch.action.get.GetResponse; +import org.elasticsearch.action.index.IndexRequest; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.action.update.UpdateRequest; +import org.elasticsearch.action.update.UpdateResponse; +import org.elasticsearch.client.Client; +import org.elasticsearch.client.transport.TransportClient; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.transport.InetSocketTransportAddress; +import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.script.Script; +import org.elasticsearch.search.SearchHit; +import org.elasticsearch.transport.client.PreBuiltTransportClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.net.InetAddress; +import java.util.*; + +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; + +/** + * Elastic Search Implementation of {@link TextIndex} + * + */ +public class TextIndexES implements TextIndex { + +/** + * The definition of the Entity we are trying to Index + */ +private final EntityDefinition docDef ; + +/** + * Thread safe ElasticSearch Java Client to perform Index operations + */ +private static Client client; + +/** + * The name of the index. Defaults to 'test' + */ +private final String indexName; + +static final String CLUSTER_NAME_PARAM = "cluster.name"; + +static final String NUM_OF_SHARDS_PARAM = "number_of_shards"; + +static final String NUM_OF_REPLICAS_PARAM = "number_of_replicas"; + +/** + * Number of maximum results to return in case no limit is specified on the search operation + */ +static final Integer MAX_RESULTS = 1; + +private boolean isMultilingual ; + +private static final Logger LOGGER = LoggerFactory.getLogger(TextIndexES.class) ; + +public TextIndexES(TextIndexConfig config, ESSettings esSettings) { + +this.indexName = esSettings.getIndexName(); +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"); +} +try { +if(client == null) { + +LOGGER.debug("Initializing the Elastic Search Java Client with settings: " + esSettings); +Settings settings = Settings.builder() +.put(CLUSTER_NAME_PARAM, esSettings.getClusterName()).build(); +List addresses = new ArrayList<>(); +for(String host: esSettings.getHostToPortMapping().keySet()) { +InetSocketTransportAddress addr = new InetSocketTransportAddress(InetAddress.getByName(host), esSettings.getHostToPortMapping().get(host)); +addresses.add(addr); +} + +InetSocketTransportAddress socketAddresses[] = new InetSocketTransportAddress[addresses.size()];
[jira] [Commented] (JENA-1305) Elastic Search Support for Apache Jena Text
[ https://issues.apache.org/jira/browse/JENA-1305?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15932466#comment-15932466 ] ASF GitHub Bot commented on JENA-1305: -- Github user anujgandharv commented on a diff in the pull request: https://github.com/apache/jena/pull/227#discussion_r106869941 --- Diff: jena-text/src/main/java/org/apache/jena/query/text/TextIndexES.java --- @@ -0,0 +1,394 @@ +/** + * 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.graph.Node; +import org.apache.jena.graph.NodeFactory; +import org.apache.jena.sparql.util.NodeFactoryExtra; +import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest; +import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse; +import org.elasticsearch.action.get.GetResponse; +import org.elasticsearch.action.index.IndexRequest; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.action.update.UpdateRequest; +import org.elasticsearch.action.update.UpdateResponse; +import org.elasticsearch.client.Client; +import org.elasticsearch.client.transport.TransportClient; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.transport.InetSocketTransportAddress; +import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.script.Script; +import org.elasticsearch.search.SearchHit; +import org.elasticsearch.transport.client.PreBuiltTransportClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.net.InetAddress; +import java.util.*; + +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; + +/** + * Elastic Search Implementation of {@link TextIndex} + * + */ +public class TextIndexES implements TextIndex { + +/** + * The definition of the Entity we are trying to Index + */ +private final EntityDefinition docDef ; + +/** + * Thread safe ElasticSearch Java Client to perform Index operations + */ +private static Client client; + +/** + * The name of the index. Defaults to 'test' + */ +private final String indexName; + +static final String CLUSTER_NAME_PARAM = "cluster.name"; + +static final String NUM_OF_SHARDS_PARAM = "number_of_shards"; + +static final String NUM_OF_REPLICAS_PARAM = "number_of_replicas"; + +/** + * Number of maximum results to return in case no limit is specified on the search operation + */ +static final Integer MAX_RESULTS = 1; + +private boolean isMultilingual ; + +private static final Logger LOGGER = LoggerFactory.getLogger(TextIndexES.class) ; + +public TextIndexES(TextIndexConfig config, ESSettings esSettings) { + +this.indexName = esSettings.getIndexName(); +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"); +} +try { +if(client == null) { + +LOGGER.debug("Initializing the Elastic Search Java Client with settings: " + esSettings); +Settings settings = Settings.builder() +.put(CLUSTER_NAME_PARAM, esSettings.getClusterName()).build(); +List addresses = new ArrayList<>(); +for(String host: esSettings.getHostToPortMapping().keySet()) { +InetSocketTransportAddress addr = new InetSocketTransportAddress(InetAddress.getByNa
[GitHub] jena pull request #227: JENA-1305 | Elastic search support for Jena Text
Github user anujgandharv commented on a diff in the pull request: https://github.com/apache/jena/pull/227#discussion_r106869941 --- Diff: jena-text/src/main/java/org/apache/jena/query/text/TextIndexES.java --- @@ -0,0 +1,394 @@ +/** + * 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.graph.Node; +import org.apache.jena.graph.NodeFactory; +import org.apache.jena.sparql.util.NodeFactoryExtra; +import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest; +import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse; +import org.elasticsearch.action.get.GetResponse; +import org.elasticsearch.action.index.IndexRequest; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.action.update.UpdateRequest; +import org.elasticsearch.action.update.UpdateResponse; +import org.elasticsearch.client.Client; +import org.elasticsearch.client.transport.TransportClient; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.transport.InetSocketTransportAddress; +import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.script.Script; +import org.elasticsearch.search.SearchHit; +import org.elasticsearch.transport.client.PreBuiltTransportClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.net.InetAddress; +import java.util.*; + +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; + +/** + * Elastic Search Implementation of {@link TextIndex} + * + */ +public class TextIndexES implements TextIndex { + +/** + * The definition of the Entity we are trying to Index + */ +private final EntityDefinition docDef ; + +/** + * Thread safe ElasticSearch Java Client to perform Index operations + */ +private static Client client; + +/** + * The name of the index. Defaults to 'test' + */ +private final String indexName; + +static final String CLUSTER_NAME_PARAM = "cluster.name"; + +static final String NUM_OF_SHARDS_PARAM = "number_of_shards"; + +static final String NUM_OF_REPLICAS_PARAM = "number_of_replicas"; + +/** + * Number of maximum results to return in case no limit is specified on the search operation + */ +static final Integer MAX_RESULTS = 1; + +private boolean isMultilingual ; + +private static final Logger LOGGER = LoggerFactory.getLogger(TextIndexES.class) ; + +public TextIndexES(TextIndexConfig config, ESSettings esSettings) { + +this.indexName = esSettings.getIndexName(); +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"); +} +try { +if(client == null) { + +LOGGER.debug("Initializing the Elastic Search Java Client with settings: " + esSettings); +Settings settings = Settings.builder() +.put(CLUSTER_NAME_PARAM, esSettings.getClusterName()).build(); +List addresses = new ArrayList<>(); +for(String host: esSettings.getHostToPortMapping().keySet()) { +InetSocketTransportAddress addr = new InetSocketTransportAddress(InetAddress.getByName(host), esSettings.getHostToPortMapping().get(host)); +addresses.add(addr); +} + +InetSocketTransportAddress socketAddresses[] = new InetSocketTransportAddress[addresses.size()];
[jira] [Commented] (JENA-1305) Elastic Search Support for Apache Jena Text
[ https://issues.apache.org/jira/browse/JENA-1305?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15932458#comment-15932458 ] ASF GitHub Bot commented on JENA-1305: -- Github user anujgandharv commented on a diff in the pull request: https://github.com/apache/jena/pull/227#discussion_r106869330 --- Diff: jena-text/src/main/java/org/apache/jena/query/text/TextIndexES.java --- @@ -0,0 +1,394 @@ +/** + * 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.graph.Node; +import org.apache.jena.graph.NodeFactory; +import org.apache.jena.sparql.util.NodeFactoryExtra; +import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest; +import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse; +import org.elasticsearch.action.get.GetResponse; +import org.elasticsearch.action.index.IndexRequest; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.action.update.UpdateRequest; +import org.elasticsearch.action.update.UpdateResponse; +import org.elasticsearch.client.Client; +import org.elasticsearch.client.transport.TransportClient; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.transport.InetSocketTransportAddress; +import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.script.Script; +import org.elasticsearch.search.SearchHit; +import org.elasticsearch.transport.client.PreBuiltTransportClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.net.InetAddress; +import java.util.*; + +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; + +/** + * Elastic Search Implementation of {@link TextIndex} + * + */ +public class TextIndexES implements TextIndex { + +/** + * The definition of the Entity we are trying to Index + */ +private final EntityDefinition docDef ; + +/** + * Thread safe ElasticSearch Java Client to perform Index operations + */ +private static Client client; + +/** + * The name of the index. Defaults to 'test' + */ +private final String indexName; + +static final String CLUSTER_NAME_PARAM = "cluster.name"; + +static final String NUM_OF_SHARDS_PARAM = "number_of_shards"; + +static final String NUM_OF_REPLICAS_PARAM = "number_of_replicas"; + +/** + * Number of maximum results to return in case no limit is specified on the search operation + */ +static final Integer MAX_RESULTS = 1; + +private boolean isMultilingual ; --- End diff -- Removed Multilingual checks from the latest commit > Elastic Search Support for Apache Jena Text > > > Key: JENA-1305 > URL: https://issues.apache.org/jira/browse/JENA-1305 > Project: Apache Jena > Issue Type: New Feature > Components: Text >Affects Versions: Jena 3.2.0 >Reporter: Anuj Kumar >Assignee: Osma Suominen > Labels: elasticsearch > Original Estimate: 240h > Remaining Estimate: 240h > > This Jira tracks the development of Jena Text ElasticSearch Implementation. > The goal is to extend Jena Text capability to index, at scale, in > ElasticSearch. This implementation would be similar to the Lucene and Solr > implementations. > We will use ES version 5.2.1 for the implementation. > The following functionalities would be supported: > * Indexing Literal values > * Updating indexed values > * Deleting Indexed values > * Custom Analyzer Support > * Configuration using Assembler as well as Java techniques. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[GitHub] jena pull request #227: JENA-1305 | Elastic search support for Jena Text
Github user anujgandharv commented on a diff in the pull request: https://github.com/apache/jena/pull/227#discussion_r106869330 --- Diff: jena-text/src/main/java/org/apache/jena/query/text/TextIndexES.java --- @@ -0,0 +1,394 @@ +/** + * 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.graph.Node; +import org.apache.jena.graph.NodeFactory; +import org.apache.jena.sparql.util.NodeFactoryExtra; +import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest; +import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse; +import org.elasticsearch.action.get.GetResponse; +import org.elasticsearch.action.index.IndexRequest; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.action.update.UpdateRequest; +import org.elasticsearch.action.update.UpdateResponse; +import org.elasticsearch.client.Client; +import org.elasticsearch.client.transport.TransportClient; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.transport.InetSocketTransportAddress; +import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.script.Script; +import org.elasticsearch.search.SearchHit; +import org.elasticsearch.transport.client.PreBuiltTransportClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.net.InetAddress; +import java.util.*; + +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; + +/** + * Elastic Search Implementation of {@link TextIndex} + * + */ +public class TextIndexES implements TextIndex { + +/** + * The definition of the Entity we are trying to Index + */ +private final EntityDefinition docDef ; + +/** + * Thread safe ElasticSearch Java Client to perform Index operations + */ +private static Client client; + +/** + * The name of the index. Defaults to 'test' + */ +private final String indexName; + +static final String CLUSTER_NAME_PARAM = "cluster.name"; + +static final String NUM_OF_SHARDS_PARAM = "number_of_shards"; + +static final String NUM_OF_REPLICAS_PARAM = "number_of_replicas"; + +/** + * Number of maximum results to return in case no limit is specified on the search operation + */ +static final Integer MAX_RESULTS = 1; + +private boolean isMultilingual ; --- End diff -- Removed Multilingual checks from the latest commit --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
Re: Remove get and updateEntity methods from TextIndex interface in jena-text?
Thank you all for for investigating. I think we can leave updateEntity in place. It's not a big deal for the ES backend to support it, currently it just calls addEntity since the necessary functionality is already there. It would be nice to have some unit tests and/or documentation for the updateEntity method though. It's a bit dangerous to have functionality used by external code with no infrastructure in place defining how it should work. But the get() method seems unnecessary, takes some effort to implement in the ES backend, and it's not clear what it's supposed to do. The only hint is what the Lucene backend does, but that's not very helpful since it works on a different level (one Lucene document per triple/quad instead of one document per entity) and may have bitrotted as well. I propose removing the TextIndex.get method and its implementation in TextIndexLucene. -Osma 17.03.2017, 11:43, Chris Dollin kirjoitti: I remember that ... just about. We do use get() and updateEntity() in our ppindexing code; I'll go and have a look at it later. It's possible that what it does has been subsumed by later changes to text indexing. Chris On 16 March 2017 at 15:49, Andy Seaborne wrote: On 16/03/17 15:42, Andy Seaborne wrote: This is already a roadbump for jena-text. There is only so much development bandwidth so if it is already a version that jena-text users are going to have to get involved in, so making considered small API changes at the same time seems the right thing to do. Deprecation only goes so far (people ignore the warnings!). I don't know the usage well enough and don't currently use jena-text. get() seems odd, updateEntity I can image might be used Added 2 years ago https://github.com/apache/jena/commit/3ff763ac18 ** ping Chris/Brian @Epimorphics ** Andy On 16/03/17 15:29, A. Soroka wrote: Sorry for my thickness, Andy, but are you saying that it makes sense to go ahead and make all the changes together, to avoid presenting a moving target for any longer than we have to? --- A. Soroka The University of Virginia Library On Mar 16, 2017, at 11:20 AM, Andy Seaborne wrote: This is a major jump for jena-text so getting in changes in the next version makes sense to me. Andy On 16/03/17 10:50, Osma Suominen wrote: Hi, In the process of developing the Elasticsearch backend for jena-text (JENA-1305), Anuj and I noticed that the methods "get" and "updateEntity" in the TextIndex interface in jena-text are never called from within Jena (not even from unit tests). Is there a reason for keeping them, or should I just remove them from the interface and its implementations? -Osma -- Osma Suominen D.Sc. (Tech), Information Systems Specialist National Library of Finland P.O. Box 26 (Kaikukatu 4) 00014 HELSINGIN YLIOPISTO Tel. +358 50 3199529 osma.suomi...@helsinki.fi http://www.nationallibrary.fi