jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [2/3] jena git commit: jena-text-es: Separate module for ElasticSearch text search
Date Wed, 26 Apr 2017 09:55:11 GMT
jena-text-es: Separate module for ElasticSearch text search


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/f56429fb
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/f56429fb
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/f56429fb

Branch: refs/heads/master
Commit: f56429fb95891a95fce3023e863b6689e9487c88
Parents: a599e48
Author: Andy Seaborne <andy@apache.org>
Authored: Sat Apr 22 10:09:14 2017 +0100
Committer: Andy Seaborne <andy@apache.org>
Committed: Sat Apr 22 22:54:08 2017 +0100

----------------------------------------------------------------------
 jena-text-es/.gitignore                         |   0
 jena-text-es/LICENSE                            | 202 +++++++++
 jena-text-es/NOTICE                             |   5 +
 jena-text-es/pom.xml                            | 226 ++++++++++
 .../main/java/examples/JenaESTextExample.java   |  95 ++++
 .../apache/jena/query/text/es/ESSettings.java   | 177 ++++++++
 .../jena/query/text/es/InitJenaTextES.java      |  34 ++
 .../query/text/es/TextESDatasetFactory.java     |  57 +++
 .../apache/jena/query/text/es/TextIndexES.java  | 451 +++++++++++++++++++
 .../text/es/assembler/TextIndexESAssembler.java | 117 +++++
 .../src/main/resources/META-INF/LICENSE         | 202 +++++++++
 jena-text-es/src/main/resources/META-INF/NOTICE |   5 +
 ...rg.apache.jena.system.JenaSubsystemLifecycle |   1 +
 jena-text-es/src/main/resources/data-es.ttl     |  46 ++
 .../org/apache/jena/query/text/properties.xml   |   9 +
 .../src/main/resources/text-config-es.ttl       |  64 +++
 .../jena/query/text/es/it/BaseESTest.java       | 111 +++++
 .../jena/query/text/es/it/TextIndexESIT.java    | 306 +++++++++++++
 .../src/test/resources/log4j.properties         |  10 +
 jena-text-es/testing/TextQuery/data.skos        |  36 ++
 jena-text-es/testing/TextQuery/data1.ttl        |  26 ++
 .../testing/TextQuery/text-config-union.ttl     |  44 ++
 jena-text-es/testing/TextQuery/text-config.ttl  |  43 ++
 jena-text-es/text-config.ttl                    |  62 +++
 jena-text/pom.xml                               |  97 +---
 .../main/java/examples/JenaESTextExample.java   |  99 ----
 .../org/apache/jena/query/text/ESSettings.java  | 177 --------
 .../jena/query/text/TextDatasetFactory.java     |  25 -
 .../org/apache/jena/query/text/TextIndexES.java | 450 ------------------
 .../query/text/assembler/TextAssembler.java     |   1 -
 .../text/assembler/TextIndexESAssembler.java    | 113 -----
 .../jena/query/text/assembler/TextVocab.java    |   2 -
 .../apache/jena/query/text/it/BaseESTest.java   | 111 -----
 .../jena/query/text/it/TextIndexESIT.java       | 306 -------------
 pom.xml                                         |   9 +-
 35 files changed, 2340 insertions(+), 1379 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/f56429fb/jena-text-es/.gitignore
----------------------------------------------------------------------
diff --git a/jena-text-es/.gitignore b/jena-text-es/.gitignore
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/jena/blob/f56429fb/jena-text-es/LICENSE
----------------------------------------------------------------------
diff --git a/jena-text-es/LICENSE b/jena-text-es/LICENSE
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/jena-text-es/LICENSE
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed 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.

http://git-wip-us.apache.org/repos/asf/jena/blob/f56429fb/jena-text-es/NOTICE
----------------------------------------------------------------------
diff --git a/jena-text-es/NOTICE b/jena-text-es/NOTICE
new file mode 100644
index 0000000..b67b596
--- /dev/null
+++ b/jena-text-es/NOTICE
@@ -0,0 +1,5 @@
+Apache Jena - jena-text module
+Copyright 2011-2017 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).

http://git-wip-us.apache.org/repos/asf/jena/blob/f56429fb/jena-text-es/pom.xml
----------------------------------------------------------------------
diff --git a/jena-text-es/pom.xml b/jena-text-es/pom.xml
new file mode 100644
index 0000000..f89f6f6
--- /dev/null
+++ b/jena-text-es/pom.xml
@@ -0,0 +1,226 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+   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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>jena-text-es</artifactId>
+  <packaging>jar</packaging>
+  <name>Apache Jena - SPARQL Text Search</name>
+  <version>3.3.0-SNAPSHOT</version>
+
+  <parent>
+    <groupId>org.apache.jena</groupId>
+    <artifactId>jena-parent</artifactId>
+    <version>19-SNAPSHOT</version>
+    <relativePath>../jena-parent</relativePath>
+  </parent>
+
+  <properties>
+    <maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ssZ</maven.build.timestamp.format>
+    <build.time.xsd>${maven.build.timestamp}</build.time.xsd>
+  </properties>
+
+  <dependencies>
+
+    <dependency>
+      <groupId>org.apache.jena</groupId>
+      <artifactId>jena-text</artifactId>
+      <version>3.3.0-SNAPSHOT</version>
+    </dependency>
+    
+    <!-- Testing support -->
+    <dependency>
+      <groupId>org.apache.jena</groupId>
+      <artifactId>jena-base</artifactId>
+      <version>3.3.0-SNAPSHOT</version>
+      <classifier>tests</classifier>
+      <scope>test</scope>
+    </dependency>
+
+    
+    <!-- Elasticsearch client -->
+    <dependency>
+      <groupId>org.elasticsearch.client</groupId>
+      <artifactId>transport</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-to-slf4j</artifactId>
+    </dependency>
+    
+    <!-- Convert commons logging to SLF4J -->
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>jcl-over-slf4j</artifactId>
+    </dependency>
+    
+  </dependencies>
+  
+  <build>
+    
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+      </plugin>
+      
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <!-- Skip the default running of this plug-in (or everything is run twice...see below) -->
+          <skip>true</skip>
+        </configuration>
+        <executions>
+          <execution>
+            <id>unit-tests</id>
+            <phase>test</phase>
+            <goals>
+              <goal>test</goal>
+            </goals>
+            <configuration>
+              <skip>false</skip>
+              <includes>
+                <include>**/TS_*.java</include>
+              </includes>
+              <excludes>
+                <exclude>**/*IT.java</exclude>
+              </excludes>
+            </configuration>
+          </execution>
+          <execution>
+            <id>integration-tests</id>
+            <phase>integration-test</phase>
+            <goals>
+              <goal>test</goal>
+            </goals>
+            <configuration>
+              <skip>false</skip>
+              <includes>
+                <include>**/*IT.java</include>
+              </includes>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>com.github.alexcojocaru</groupId>
+        <artifactId>elasticsearch-maven-plugin</artifactId>
+        <!-- REPLACE THE FOLLOWING WITH THE PLUGIN VERSION YOU NEED -->
+        <version>5.2</version>
+        <configuration>
+          <clusterName>elasticsearch</clusterName>
+          <transportPort>9500</transportPort>
+          <httpPort>9400</httpPort>
+        </configuration>
+        <executions>
+          <!--
+              The elasticsearch maven plugin goals are by default bound to the
+              pre-integration-test and post-integration-test phases
+          -->
+          <execution>
+            <id>start-elasticsearch</id>
+            <phase>pre-integration-test</phase>
+            <goals>
+              <goal>runforked</goal>
+            </goals>
+          </execution>
+          <execution>
+            <id>stop-elasticsearch</id>
+            <phase>post-integration-test</phase>
+            <goals>
+              <goal>stop</goal>
+                    </goals>
+          </execution>
+            </executions>
+      </plugin>
+      
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+      </plugin>
+
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-source-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>attach-sources</id>
+            <goals>
+              <goal>jar-no-fork</goal>
+            </goals>
+          </execution>
+          <!-- Only material in the main jar <execution> <id>attach-sources-test</id> 
+               <goals> <goal>test-jar-no-fork</goal> </goals> </execution> 
+               -->
+        </executions>
+      </plugin>
+
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-javadoc-plugin</artifactId>
+        <configuration>
+          <version>true</version>
+          <show>public</show>
+          <quiet>true</quiet>
+          <encoding>UTF-8</encoding>
+          <windowtitle>${project.name} ${project.version}</windowtitle>
+          <doctitle>${project.name} ${project.version}</doctitle>
+          <bottom>Licenced under the Apache License, Version 2.0</bottom>
+        </configuration>
+      </plugin>
+
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-resources-plugin</artifactId>
+        <configuration>
+          <encoding>UTF-8</encoding>
+        </configuration>
+      </plugin>
+
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-dependency-plugin</artifactId>
+        <configuration>
+          <overWriteReleases>false</overWriteReleases>
+          <overWriteIfNewer>true</overWriteIfNewer>
+        </configuration>
+      </plugin>
+
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-eclipse-plugin</artifactId>
+        <configuration>
+          <!-- By default, have separate Eclipse and maven build areas -->
+          <buildOutputDirectory>${project.build.directory}/classes</buildOutputDirectory>
+          <downloadSources>true</downloadSources>
+          <downloadJavadocs>false</downloadJavadocs>
+        </configuration>
+      </plugin>
+
+    </plugins>
+    
+  </build>
+  
+</project>

http://git-wip-us.apache.org/repos/asf/jena/blob/f56429fb/jena-text-es/src/main/java/examples/JenaESTextExample.java
----------------------------------------------------------------------
diff --git a/jena-text-es/src/main/java/examples/JenaESTextExample.java b/jena-text-es/src/main/java/examples/JenaESTextExample.java
new file mode 100644
index 0000000..f48b291
--- /dev/null
+++ b/jena-text-es/src/main/java/examples/JenaESTextExample.java
@@ -0,0 +1,95 @@
+/**
+ * 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 examples;
+
+import org.apache.jena.atlas.lib.StrUtils;
+import org.apache.jena.query.*;
+import org.apache.jena.sparql.util.QueryExecUtils;
+
+/**
+ * Simple example class to test the {@link org.apache.jena.query.text.es.assembler.TextIndexESAssembler}
+ * For this class to work properly, an elasticsearch node should be up and running, otherwise it will fail.
+ * You can find the details of downloading and running an ElasticSearch version here: https://www.elastic.co/downloads/past-releases/elasticsearch-5-2-1
+ * Unzip the file in your favourite directory and then execute the appropriate file under the bin directory.
+ * It will take less than a minute.
+ * In order to visualize what is written in ElasticSearch, you need to download and run Kibana: https://www.elastic.co/downloads/kibana
+ * To run kibana, just go to the bin directory and execute the appropriate file.
+ * We need to resort to this mechanism as ElasticSearch has stopped supporting embedded ElasticSearch.
+ *
+ * In addition we cant have it in the test package because ElasticSearch
+ * detects the thread origin and stops us from instantiating a client.
+ */
+public class JenaESTextExample {
+
+    public static void main(String[] args) {
+
+        queryData(loadData(createAssembler()));
+    }
+
+
+    private static Dataset createAssembler() {
+        String assemblerFile = "text-config-es.ttl";
+        Dataset ds = DatasetFactory.assemble(assemblerFile, "http://localhost/jena_example/#text_dataset") ;
+        return ds;
+    }
+
+    private static Dataset loadData(Dataset ds) {
+        JenaTextExample1.loadData(ds, "data-es.ttl");
+        return ds;
+    }
+
+    /**
+     * Query Data
+     * @param ds
+     */
+    private static void queryData(Dataset ds) {
+        queryDataWithoutProperty(ds);
+    }
+
+    public static void queryDataWithoutProperty(Dataset dataset)
+    {
+
+
+        String pre = StrUtils.strjoinNL
+                ( "PREFIX : <http://example/>"
+                        , "PREFIX text: <http://jena.apache.org/text#>"
+                        , "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>") ;
+
+        String qs = StrUtils.strjoinNL
+                ( "SELECT * "
+//                        , " { ?s text:query (rdfs:comment 'this' 'lang:en') ;"
+                        , " { ?s text:query ('this' 'lang:en*') ;"
+//                        , " { ?s text:query ('this' 'lang:en-GB') ;"
+//                        , " { ?s text:query (rdfs:comment 'this' 'lang:en-GB') ;"
+//                        , " { ?s text:query (rdfs:comment 'this' 'lang:*') ;"
+//                        , " { ?s text:query (rdfs:comment 'this' 'lang:none') ;"
+//                        , " { ?s text:query (rdfs:comment 'this') ;"
+//                        , " { ?s text:query ('X1' 'lang:en') ;"
+                        , "      rdfs:label ?label"
+                        , " }") ;
+
+        dataset.begin(ReadWrite.READ) ;
+        try {
+            Query q = QueryFactory.create(pre+"\n"+qs) ;
+            QueryExecution qexec = QueryExecutionFactory.create(q , dataset) ;
+            QueryExecUtils.executeQuery(q, qexec) ;
+        } finally { dataset.end() ; }
+
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/f56429fb/jena-text-es/src/main/java/org/apache/jena/query/text/es/ESSettings.java
----------------------------------------------------------------------
diff --git a/jena-text-es/src/main/java/org/apache/jena/query/text/es/ESSettings.java b/jena-text-es/src/main/java/org/apache/jena/query/text/es/ESSettings.java
new file mode 100644
index 0000000..b34d819
--- /dev/null
+++ b/jena-text-es/src/main/java/org/apache/jena/query/text/es/ESSettings.java
@@ -0,0 +1,177 @@
+/**
+ * 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.es;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Settings for ElasticSearch based indexing
+ */
+public class ESSettings {
+
+    /**
+     * Map of hosts and ports. The host could also be an IP Address
+     */
+    private Map<String,Integer> hostToPortMapping;
+
+    /**
+     * Name of the Cluster. Defaults to 'elasticsearch'
+     */
+    private String clusterName;
+
+    /**
+     * Number of shards. Defaults to '1'
+     */
+    private Integer shards;
+
+    /**
+     * Number of replicas. Defaults to '1'
+     */
+    private Integer replicas;
+
+    /**
+     * Name of the index. Defaults to 'jena-text'
+     */
+    private String indexName;
+
+
+    public Map<String, Integer> getHostToPortMapping() {
+        return hostToPortMapping;
+    }
+
+    public void setHostToPortMapping(Map<String, Integer> hostToPortMapping) {
+        this.hostToPortMapping = hostToPortMapping;
+    }
+
+    public ESSettings.Builder builder() {
+        return new ESSettings.Builder();
+    }
+
+    /**
+     * Convenient builder class for building ESSettings
+     */
+    public static class Builder {
+
+        ESSettings settings;
+
+        public Builder() {
+            this.settings = new ESSettings();
+            this.settings.setClusterName("elasticsearch");
+            this.settings.setShards(1);
+            this.settings.setReplicas(1);
+            this.settings.setHostToPortMapping(new HashMap<>());
+            this.settings.setIndexName("jena-text");
+        }
+
+
+        public Builder indexName(String indexName) {
+            if(indexName != null && !indexName.isEmpty()) {
+                this.settings.setIndexName(indexName);
+            }
+            return this;
+        }
+
+        public Builder clusterName(String clusterName) {
+            if(clusterName != null && !clusterName.isEmpty()) {
+                this.settings.setClusterName(clusterName);
+            }
+            return this;
+
+        }
+
+        public Builder shards(Integer shards) {
+            if (shards != null) {
+                this.settings.setShards(shards);
+            }
+            return this;
+        }
+
+        public Builder replicas(Integer replicas) {
+            if(replicas != null) {
+                this.settings.setReplicas(replicas);
+            }
+            return this;
+        }
+
+        public Builder hostAndPort(String host, Integer port) {
+            if(host != null && port != null) {
+                this.settings.getHostToPortMapping().put(host, port);
+            }
+            return this;
+
+        }
+
+        public Builder hostAndPortMap(Map<String, Integer> hostAndPortMap) {
+            if(hostAndPortMap != null) {
+                this.settings.getHostToPortMapping().putAll(hostAndPortMap);
+            }
+
+            return this;
+        }
+
+        public ESSettings build() {
+            return this.settings;
+        }
+
+    }
+
+    public String getClusterName() {
+        return clusterName;
+    }
+
+    public void setClusterName(String clusterName) {
+        this.clusterName = clusterName;
+    }
+
+    public Integer getShards() {
+        return shards;
+    }
+
+    public void setShards(Integer shards) {
+        this.shards = shards;
+    }
+
+    public Integer getReplicas() {
+        return replicas;
+    }
+
+    public void setReplicas(Integer replicas) {
+        this.replicas = replicas;
+    }
+
+    public String getIndexName() {
+        return indexName;
+    }
+
+    public void setIndexName(String indexName) {
+        this.indexName = indexName;
+    }
+
+
+    @Override
+    public String toString() {
+        return "ESSettings{" +
+                "hostToPortMapping=" + hostToPortMapping +
+                ", clusterName='" + clusterName + '\'' +
+                ", shards=" + shards +
+                ", replicas=" + replicas +
+                ", indexName='" + indexName +
+                '}';
+    }
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/f56429fb/jena-text-es/src/main/java/org/apache/jena/query/text/es/InitJenaTextES.java
----------------------------------------------------------------------
diff --git a/jena-text-es/src/main/java/org/apache/jena/query/text/es/InitJenaTextES.java b/jena-text-es/src/main/java/org/apache/jena/query/text/es/InitJenaTextES.java
new file mode 100644
index 0000000..81d764a
--- /dev/null
+++ b/jena-text-es/src/main/java/org/apache/jena/query/text/es/InitJenaTextES.java
@@ -0,0 +1,34 @@
+/**
+ * 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.es;
+
+import org.apache.jena.query.text.TextQuery;
+import org.apache.jena.system.JenaSubsystemLifecycle ;
+
+public class InitJenaTextES implements JenaSubsystemLifecycle {
+    @Override
+    public void start() {
+        TextQuery.init() ;
+    }
+
+    @Override
+    public void stop() {
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/jena/blob/f56429fb/jena-text-es/src/main/java/org/apache/jena/query/text/es/TextESDatasetFactory.java
----------------------------------------------------------------------
diff --git a/jena-text-es/src/main/java/org/apache/jena/query/text/es/TextESDatasetFactory.java b/jena-text-es/src/main/java/org/apache/jena/query/text/es/TextESDatasetFactory.java
new file mode 100644
index 0000000..ad05d23
--- /dev/null
+++ b/jena-text-es/src/main/java/org/apache/jena/query/text/es/TextESDatasetFactory.java
@@ -0,0 +1,57 @@
+/**
+ * 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.es;
+
+import org.apache.jena.query.Dataset ;
+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.TextIndexConfig;
+import org.apache.jena.system.JenaSystem ;
+
+public class TextESDatasetFactory
+{
+    static { JenaSystem.init(); }
+    
+    /**
+     * Create an ElasticSearch based Index and return a Dataset based on this index
+     * @param base the base {@link Dataset}
+     * @param config {@link TextIndexConfig} containing the {@link EntityDefinition}
+     * @param settings ElasticSearch specific settings for initializing and connecting to an ElasticSearch Cluster
+     * @return The config definition for the index instantiation
+     */
+    public static Dataset createES(Dataset base, TextIndexConfig config, ESSettings settings)
+    {
+        TextIndex index = createESIndex(config, settings) ;
+        return TextDatasetFactory.create(base, index, true) ;
+    }
+
+    /**
+     * Create an ElasticSearch based Index
+     * @param config {@link TextIndexConfig} containing the {@link EntityDefinition}
+     * @param settings ElasticSearch specific settings for initializing and connecting to an ElasticSearch Cluster
+     * @return a configured instance of TextIndexES
+     */
+    public static TextIndex createESIndex(TextIndexConfig config, ESSettings settings)
+    {
+        return new TextIndexES(config, settings) ;
+    }
+
+}
+

http://git-wip-us.apache.org/repos/asf/jena/blob/f56429fb/jena-text-es/src/main/java/org/apache/jena/query/text/es/TextIndexES.java
----------------------------------------------------------------------
diff --git a/jena-text-es/src/main/java/org/apache/jena/query/text/es/TextIndexES.java b/jena-text-es/src/main/java/org/apache/jena/query/text/es/TextIndexES.java
new file mode 100644
index 0000000..7c55488
--- /dev/null
+++ b/jena-text-es/src/main/java/org/apache/jena/query/text/es/TextIndexES.java
@@ -0,0 +1,451 @@
+/**
+ * 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.es;
+
+import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
+
+import java.net.InetAddress;
+import java.util.*;
+
+import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.apache.jena.graph.Node;
+import org.apache.jena.graph.NodeFactory;
+import org.apache.jena.query.text.*;
+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.engine.DocumentMissingException;
+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;
+
+/**
+ * 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 'jena-text'
+     */
+    private final String indexName;
+
+    /**
+     * The parameter representing the cluster name key
+     */
+    static final String CLUSTER_NAME_PARAM = "cluster.name";
+
+    /**
+     * The parameter representing the number of shards key
+     */
+    static final String NUM_OF_SHARDS_PARAM = "number_of_shards";
+
+    /**
+     * The parameter representing the number of replicas key
+     */
+    static final String NUM_OF_REPLICAS_PARAM = "number_of_replicas";
+
+    private static final String DASH = "-";
+
+    private static final String UNDERSCORE = "_";
+
+    private static final String COLON = ":";
+
+    private static final String ASTERISK = "*";
+
+    /**
+     * ES Script for adding/updating the document in the index.
+     * The main reason to use scripts is because we want to modify the values of the fields that contains an array of values
+     */
+    private static final String ADD_UPDATE_SCRIPT = "if((ctx._source == null) || (ctx._source.<fieldName> == null) || (ctx._source.<fieldName>.empty == true)) " +
+            "{ctx._source.<fieldName>=[params.fieldValue] } else {ctx._source.<fieldName>.add(params.fieldValue)}";
+
+    /**
+     * ES Script for deleting a specific value in the field for the given document in the index.
+     * The main reason to use scripts is because we want to delete specific value of the field that contains an array of values
+     */
+    private static final String DELETE_SCRIPT = "if((ctx._source != null) && (ctx._source.<fieldToRemove> != null) && (ctx._source.<fieldToRemove>.empty != true) " +
+            "&& (ctx._source.<fieldToRemove>.indexOf(params.valueToRemove) >= 0)) " +
+            "{ctx._source.<fieldToRemove>.remove(ctx._source.<fieldToRemove>.indexOf(params.valueToRemove))}";
+
+    /**
+     * Number of maximum results to return in case no limit is specified on the search operation
+     */
+    static final Integer MAX_RESULTS = 10000;
+
+    private static final Logger LOGGER      = LoggerFactory.getLogger(TextIndexES.class) ;
+
+    /**
+     * Construct an instance of {@link TextIndexES} based on provided {@link TextIndexConfig} and {@link ESSettings}
+     * The constructor is responsible for initializing a {@link TransportClient} based on the provided configs
+     * and create index based on the provided {@link ESSettings}
+     * @param config an instance of {@link TextIndexConfig}
+     * @param esSettings an instance of {@link ESSettings}
+     */
+    public TextIndexES(TextIndexConfig config, ESSettings esSettings) {
+
+        this.indexName = esSettings.getIndexName();
+        this.docDef = config.getEntDef();
+        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<InetSocketTransportAddress> 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()];
+                TransportClient tc = new PreBuiltTransportClient(settings);
+                tc.addTransportAddresses(addresses.toArray(socketAddresses));
+                client = tc;
+                LOGGER.debug("Successfully initialized the client");
+            }
+
+            IndicesExistsResponse exists = client.admin().indices().exists(new IndicesExistsRequest(indexName)).get();
+            if(!exists.isExists()) {
+                Settings indexSettings = Settings.builder()
+                        .put(NUM_OF_SHARDS_PARAM, esSettings.getShards())
+                        .put(NUM_OF_REPLICAS_PARAM, esSettings.getReplicas())
+                        .build();
+                LOGGER.debug("Index with name " + indexName + " does not exist yet. Creating one with settings: " + indexSettings.toString());
+                client.admin().indices().prepareCreate(indexName).setSettings(indexSettings).get();
+            }
+        }catch (Exception e) {
+            throw new TextIndexException("Exception occurred while instantiating ElasticSearch Text Index", e);
+        }
+    }
+
+
+    /**
+     * Constructor used mainly for performing Integration tests
+     * @param config an instance of {@link TextIndexConfig}
+     * @param client an instance of {@link TransportClient}. The client should already have been initialized with an index
+     */
+    public TextIndexES(TextIndexConfig config, Client client, String indexName) {
+        this.docDef = config.getEntDef();
+        this.client = client;
+        this.indexName = indexName;
+    }
+
+    /**
+     * We do not have any specific logic to perform before committing
+     */
+    @Override
+    public void prepareCommit() {
+        //Do Nothing
+
+    }
+
+    /**
+     * Commit happens in the individual get/add/delete operations
+     */
+    @Override
+    public void commit() {
+        // Do Nothing
+    }
+
+    /**
+     * We do not do rollback
+     */
+    @Override
+    public void rollback() {
+       //Do Nothing
+
+    }
+
+    /**
+     * We don't have resources that need to be closed explicitely
+     */
+    @Override
+    public void close() {
+        // Do Nothing
+
+    }
+
+    /**
+     * Update an Entity. Since we are doing Upserts in add entity anyways, we simply call {@link #addEntity(Entity)}
+     * method that takes care of updating the Entity as well.
+     * @param entity the entity to update.
+     */
+    @Override
+    public void updateEntity(Entity entity) {
+        //Since Add entity also updates the indexed document in case it already exists,
+        // we can simply call the addEntity from here.
+        addEntity(entity);
+    }
+
+
+    /**
+     * Add an Entity to the ElasticSearch Index.
+     * The entity will be added as a new document in ES, if it does not already exists.
+     * If the Entity exists, then the entity will simply be updated.
+     * The entity will never be replaced.
+     * @param entity the entity to add
+     */
+    @Override
+    public void addEntity(Entity entity) {
+        LOGGER.debug("Adding/Updating the entity in ES");
+
+        //The field that has a not null value in the current Entity instance.
+        //Required, mainly for building a script for the update command.
+        String fieldToAdd = null;
+        String fieldValueToAdd = null;
+        try {
+            XContentBuilder builder = jsonBuilder()
+                    .startObject();
+
+            for(String field: docDef.fields()) {
+                if(entity.get(field) != null) {
+                    if(entity.getLanguage() != null && !entity.getLanguage().isEmpty()) {
+                        //We make sure that the field name contains all underscore and no dash (for eg. when the lang value is en-GB)
+                        //The reason to do this is because the script fails with exception in case we have "-" in field name.
+                        fieldToAdd = normalizeFieldName(field, entity.getLanguage());
+                    } else {
+                        fieldToAdd = field;
+                    }
+
+                    fieldValueToAdd = (String) entity.get(field);
+                    builder = builder.field(fieldToAdd, Arrays.asList(fieldValueToAdd));
+                    break;
+                } else {
+                    //We are making sure that the field is at-least added to the index.
+                    //This will help us tremendously when we are appending the data later in an already indexed document.
+                    builder = builder.field(field, Collections.emptyList());
+                }
+            }
+
+            builder = builder.endObject();
+            IndexRequest indexRequest = new IndexRequest(indexName, docDef.getEntityField(), entity.getId())
+                    .source(builder);
+
+            String addUpdateScript = ADD_UPDATE_SCRIPT.replaceAll("<fieldName>", fieldToAdd);
+            Map<String, Object> params = new HashMap<>();
+            params.put("fieldValue", fieldValueToAdd);
+
+            UpdateRequest upReq = new UpdateRequest(indexName, docDef.getEntityField(), entity.getId())
+                    .script(new Script(Script.DEFAULT_SCRIPT_TYPE, Script.DEFAULT_SCRIPT_LANG, addUpdateScript, params))
+                    .upsert(indexRequest);
+
+            UpdateResponse response = client.update(upReq).get();
+
+            LOGGER.debug("Received the following Update response : " + response + " for the following entity: " + entity);
+
+        } catch(Exception e) {
+            throw new TextIndexException("Unable to Index the Entity in ElasticSearch.", e);
+        }
+    }
+
+    /**
+     * Delete the value of the entity from the existing document, if any.
+     * The document itself will never get deleted. Only the value will get deleted.
+     * @param entity entity whose value needs to be deleted
+     */
+    @Override
+    public void deleteEntity(Entity entity) {
+
+        String fieldToRemove = null;
+        String valueToRemove = null;
+        for(String field : docDef.fields()) {
+            if(entity.get(field) != null) {
+                fieldToRemove = field;
+                if(entity.getLanguage()!= null && !entity.getLanguage().isEmpty()) {
+                    fieldToRemove = normalizeFieldName(fieldToRemove, entity.getLanguage());
+                }
+                valueToRemove = (String)entity.get(field);
+                break;
+            }
+        }
+
+        if(fieldToRemove != null && valueToRemove != null) {
+
+            LOGGER.debug("deleting content related to entity: " + entity.getId());
+            String deleteScript = DELETE_SCRIPT.replaceAll("<fieldToRemove>", fieldToRemove);
+            Map<String,Object> params = new HashMap<>();
+            params.put("valueToRemove", valueToRemove);
+
+            UpdateRequest updateRequest = new UpdateRequest(indexName, docDef.getEntityField(), entity.getId())
+                    .script(new Script(Script.DEFAULT_SCRIPT_TYPE, Script.DEFAULT_SCRIPT_LANG,deleteScript,params));
+
+            try {
+                client.update(updateRequest).get();
+            }catch(Exception e) {
+                if( ExceptionUtils.getRootCause(e) instanceof DocumentMissingException) {
+                    LOGGER.debug("Trying to delete values from a missing document. Ignoring deletion of entity: ", entity);
+                } else {
+                    throw new TextIndexException("Unable to delete entity.", e);
+                }
+            }
+        }
+    }
+
+    /**
+     * Get an Entity given the subject Id
+     * @param uri the subject Id of the entity
+     * @return a map of field name and field values;
+     */
+    @Override
+    public Map<String, Node> get(String uri) {
+
+        GetResponse response;
+        Map<String, Node> result = new HashMap<>();
+
+        if(uri != null) {
+            response = client.prepareGet(indexName, docDef.getEntityField(), uri).get();
+            if(response != null && !response.isSourceEmpty()) {
+                String entityField = response.getId();
+                Node entity = NodeFactory.createURI(entityField) ;
+                result.put(docDef.getEntityField(), entity);
+                Map<String, Object> source = response.getSource();
+                for (String field: docDef.fields()) {
+                    Object fieldResponse = source.get(field);
+
+                    if(fieldResponse == null) {
+                        //We wont return it.
+                        continue;
+                    }
+                    else if(fieldResponse instanceof List<?>) {
+                        //We are storing the values of fields as a List always.
+                        //If there are values stored in the list, then we return the first value,
+                        // else we do not include the field in the returned Map of Field -> Node Mapping
+                        List<?> responseList = (List<?>)fieldResponse;
+                        if(responseList != null && responseList.size() > 0) {
+                            String fieldValue = (String)responseList.get(0);
+                            Node fieldNode = NodeFactoryExtra.createLiteralNode(fieldValue, null, null);
+                            result.put(field, fieldNode);
+                        }
+                    }
+                }
+            }
+        }
+
+        return result;
+    }
+
+
+    @Override
+    public List<TextHit> query(Node property, String qs, String graphURI, String lang) {
+        return query(property, qs, graphURI, lang, MAX_RESULTS);
+    }
+
+    /**
+     * Query the ElasticSearch for the given Node, with the given query String and limit.
+     * @param property the node property to make a search for
+     * @param qs the query string
+     * @param limit limit on the number of records to return
+     * @return List of {@link TextHit}s containing the documents that have been found
+     */
+    @Override
+    public List<TextHit> query(Node property, String qs, String graphURI, String lang, int limit) {
+        if(property != null) {
+            qs = parse(property.getLocalName(), qs, lang);
+        } else {
+            qs = parse(null, qs, lang);
+        }
+
+        LOGGER.debug("Querying ElasticSearch for QueryString: " + qs);
+        SearchResponse response = client.prepareSearch(indexName)
+                .setTypes(docDef.getEntityField())
+                .setQuery(QueryBuilders.queryStringQuery(qs))
+                // Not fetching the source because we are currently not interested
+                // in the actual values but only Id of the document. This will also speed up search
+                .setFetchSource(false)
+                .setFrom(0).setSize(limit)
+                .get();
+
+        List<TextHit> results = new ArrayList<>() ;
+        for (SearchHit hit : response.getHits()) {
+
+            //It has been decided to return NULL literal values for now.
+            String entityField = hit.getId();
+            Node entityNode = TextQueryFuncs.stringToNode(entityField);
+            Float score = hit.getScore();
+            TextHit textHit = new TextHit(entityNode, score, null);
+            results.add(textHit);
+
+        }
+        return results;
+    }
+
+    @Override
+    public EntityDefinition getDocDef() {
+        return docDef ;
+    }
+
+    private String parse(String fieldName, String qs, String lang) {
+        if(fieldName != null && !fieldName.isEmpty()) {
+            if(lang != null && !lang.equals("none")) {
+                if (!ASTERISK.equals(lang)) {
+                    fieldName = fieldName + UNDERSCORE + lang.replaceAll(DASH, UNDERSCORE);
+                    qs = fieldName + COLON + qs;
+                } else {
+                    if(!qs.contains("\\*")) {
+                        fieldName = fieldName + ASTERISK;
+                        qs = fieldName + COLON + qs;
+                    }
+                }
+
+                } else {
+                //Lang is null, but field name is not null
+                qs = fieldName + COLON + qs;
+
+            }
+        }
+        //We do this to enable wild card search
+        return qs.replaceAll("\\*", "\\\\*");
+
+    }
+
+    private String normalizeFieldName(String fieldName, String lang) {
+        //We know that the lang field is not null already
+        StringBuilder sb = new StringBuilder(fieldName);
+        return sb.append(UNDERSCORE).append(lang.replaceAll(DASH,UNDERSCORE)).toString();
+
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/f56429fb/jena-text-es/src/main/java/org/apache/jena/query/text/es/assembler/TextIndexESAssembler.java
----------------------------------------------------------------------
diff --git a/jena-text-es/src/main/java/org/apache/jena/query/text/es/assembler/TextIndexESAssembler.java b/jena-text-es/src/main/java/org/apache/jena/query/text/es/assembler/TextIndexESAssembler.java
new file mode 100644
index 0000000..0ed4384
--- /dev/null
+++ b/jena-text-es/src/main/java/org/apache/jena/query/text/es/assembler/TextIndexESAssembler.java
@@ -0,0 +1,117 @@
+/**
+ * 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.es.assembler;
+
+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.TextIndex;
+import org.apache.jena.query.text.TextIndexConfig;
+import org.apache.jena.query.text.TextIndexException;
+import org.apache.jena.query.text.es.*;
+import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.sparql.util.graph.GraphUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.apache.jena.query.text.assembler.TextVocab.*;
+
+public class TextIndexESAssembler extends AssemblerBase {
+
+    private static Logger LOGGER      = LoggerFactory.getLogger(TextIndexESAssembler.class) ;
+
+    protected static final String COMMA = ",";
+    protected static final String COLON = ":";
+    /*
+    <#index> a :TextIndexES ;
+        text:serverList "127.0.0.1:9300,127.0.0.2:9400,127.0.0.3:9500" ; #Comma separated list of hosts:ports
+        text:clusterName "elasticsearch"
+        text:shards "1"
+        text:replicas "1"
+        text:entityMap <#endMap> ;
+        .
+    */
+    
+    @Override
+    public TextIndex open(Assembler a, Resource root, Mode mode) {
+        try {
+            String listOfHostsAndPorts = GraphUtils.getAsStringValue(root, pServerList) ;
+            if(listOfHostsAndPorts == null || listOfHostsAndPorts.isEmpty()) {
+                throw new TextIndexException("Mandatory property text:serverList (containing the comma-separated list of host:port) property is not specified. " +
+                        "An example value for the property: 127.0.0.1:9300");
+            }
+            String[] hosts = listOfHostsAndPorts.split(COMMA);
+            Map<String,Integer> hostAndPortMapping = new HashMap<>();
+            for(String host : hosts) {
+                String[] hostAndPort = host.split(COLON);
+                if(hostAndPort.length < 2) {
+                    LOGGER.error("Either the host or the port value is missing.Please specify the property in host:port format. " +
+                            "Both parts are mandatory. Ignoring this value. Moving to the next one.");
+                    continue;
+                }
+                hostAndPortMapping.put(hostAndPort[0], Integer.valueOf(hostAndPort[1]));
+            }
+
+            String clusterName = GraphUtils.getAsStringValue(root, pClusterName);
+            if(clusterName == null || clusterName.isEmpty()) {
+                LOGGER.warn("ClusterName property is not specified. Defaulting to 'elasticsearch'");
+                clusterName = "elasticsearch";
+            }
+
+            String numberOfShards = GraphUtils.getAsStringValue(root, pShards);
+            if(numberOfShards == null || numberOfShards.isEmpty()) {
+                LOGGER.warn("shards property is not specified. Defaulting to '1'");
+                numberOfShards = "1";
+            }
+
+            String replicationFactor = GraphUtils.getAsStringValue(root, pReplicas);
+            if(replicationFactor == null || replicationFactor.isEmpty()) {
+                LOGGER.warn("replicas property is not specified. Defaulting to '1'");
+                replicationFactor = "1";
+            }
+
+            String indexName = GraphUtils.getAsStringValue(root, pIndexName);
+            if(indexName == null || indexName.isEmpty()) {
+                LOGGER.warn("index Name property is not specified. Defaulting to 'jena-text'");
+                indexName = "jena-text";
+            }
+
+            Resource r = GraphUtils.getResourceValue(root, pEntityMap) ;
+            EntityDefinition docDef = (EntityDefinition)a.open(r) ;
+            TextIndexConfig config = new TextIndexConfig(docDef);
+
+            //We have to create an ES specific settings class in order to pass the Index Initialization specific properties.
+            ESSettings settings = new ESSettings().builder()
+                    .clusterName(clusterName)
+                    .hostAndPortMap(hostAndPortMapping)
+                    .shards(Integer.valueOf(numberOfShards))
+                    .replicas(Integer.valueOf(replicationFactor))
+                    .indexName(indexName)
+                    .build();
+
+            return TextESDatasetFactory.createESIndex(config, settings) ;
+        } catch (Exception e) {
+            throw new TextIndexException("An exception occurred while trying to open/load the Assembler configuration. ", e);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/f56429fb/jena-text-es/src/main/resources/META-INF/LICENSE
----------------------------------------------------------------------
diff --git a/jena-text-es/src/main/resources/META-INF/LICENSE b/jena-text-es/src/main/resources/META-INF/LICENSE
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/jena-text-es/src/main/resources/META-INF/LICENSE
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed 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.

http://git-wip-us.apache.org/repos/asf/jena/blob/f56429fb/jena-text-es/src/main/resources/META-INF/NOTICE
----------------------------------------------------------------------
diff --git a/jena-text-es/src/main/resources/META-INF/NOTICE b/jena-text-es/src/main/resources/META-INF/NOTICE
new file mode 100644
index 0000000..b67b596
--- /dev/null
+++ b/jena-text-es/src/main/resources/META-INF/NOTICE
@@ -0,0 +1,5 @@
+Apache Jena - jena-text module
+Copyright 2011-2017 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).

http://git-wip-us.apache.org/repos/asf/jena/blob/f56429fb/jena-text-es/src/main/resources/META-INF/services/org.apache.jena.system.JenaSubsystemLifecycle
----------------------------------------------------------------------
diff --git a/jena-text-es/src/main/resources/META-INF/services/org.apache.jena.system.JenaSubsystemLifecycle b/jena-text-es/src/main/resources/META-INF/services/org.apache.jena.system.JenaSubsystemLifecycle
new file mode 100644
index 0000000..b9a66ea
--- /dev/null
+++ b/jena-text-es/src/main/resources/META-INF/services/org.apache.jena.system.JenaSubsystemLifecycle
@@ -0,0 +1 @@
+org.apache.jena.query.text.es.InitJenaTextES

http://git-wip-us.apache.org/repos/asf/jena/blob/f56429fb/jena-text-es/src/main/resources/data-es.ttl
----------------------------------------------------------------------
diff --git a/jena-text-es/src/main/resources/data-es.ttl b/jena-text-es/src/main/resources/data-es.ttl
new file mode 100644
index 0000000..8813e86
--- /dev/null
+++ b/jena-text-es/src/main/resources/data-es.ttl
@@ -0,0 +1,46 @@
+   # 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.
+
+@prefix :        <http://example/> .
+@prefix xsd:     <http://www.w3.org/2001/XMLSchema#> .
+@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
+
+:s a :Thing ;
+   :p :123 ;
+   rdfs:label "Thing 1"@en ;
+   rdfs:comment "It's a complicated comment"@en ;
+   rdfs:comment "this is another comment"@en ;
+   rdfs:comment "this is en GB comment"@en-GB ;
+   :id 123 .
+
+:s1 a :Thing ;
+   :p :123 ;
+   rdfs:label "Thing 2"@en ;
+   :id 123 .
+
+:s2 a :Thing ;
+   :p :123 ;
+   rdfs:label "Whatever"@en ;
+   :id 123 .
+
+   
+:x1 rdfs:label "X2 word"@en .
+:x1 rdfs:label "X1 another word" .
+:x2 rdfs:label "X2 word" .
+:x3 rdfs:label "X3 word" .
+:x3 rdfs:label "X4 word" .
+:x1 rdfs:label "X9 word" .
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jena/blob/f56429fb/jena-text-es/src/main/resources/org/apache/jena/query/text/properties.xml
----------------------------------------------------------------------
diff --git a/jena-text-es/src/main/resources/org/apache/jena/query/text/properties.xml b/jena-text-es/src/main/resources/org/apache/jena/query/text/properties.xml
new file mode 100644
index 0000000..3316b85
--- /dev/null
+++ b/jena-text-es/src/main/resources/org/apache/jena/query/text/properties.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<!--  Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0 -->
+<properties version="1.0">
+  <comment>jena-text system properties</comment>
+  <entry key="org.apache.jena.query.text.version">${project.version}</entry>
+  <entry key="org.apache.jena.query.text.datetime">${build.time.xsd}</entry>
+</properties>
+ 
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jena/blob/f56429fb/jena-text-es/src/main/resources/text-config-es.ttl
----------------------------------------------------------------------
diff --git a/jena-text-es/src/main/resources/text-config-es.ttl b/jena-text-es/src/main/resources/text-config-es.ttl
new file mode 100644
index 0000000..7a03384
--- /dev/null
+++ b/jena-text-es/src/main/resources/text-config-es.ttl
@@ -0,0 +1,64 @@
+    # 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.
+
+ ## Example of a TDB dataset and text index for ElasticSearch
+
+@prefix :        <http://localhost/jena_example/#> .
+@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
+@prefix tdb:     <http://jena.hpl.hp.com/2008/tdb#> .
+@prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .
+@prefix text:    <http://jena.apache.org/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:TextIndexES      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     <#indexES> ;
+    .
+
+<#dataset> rdf:type      tdb:DatasetTDB ;
+    tdb:location "--mem--" ;
+    .
+
+<#indexES> a text:TextIndexES ;
+    text:serverList "127.0.0.1:9300" ; # A comma-separated list of Host:Port values of the ElasticSearch Cluster nodes.
+    text:clusterName "elasticsearch" ; # Name of the ElasticSearch Cluster. If not specified defaults to 'elasticsearch'
+    text:shards "1" ;                  # The number of shards for the index. Defaults to 1
+    text:replicas "1" ;                # The number of replicas for the index. Defaults to 1
+    text:indexName "jena-text" ;       # Name of the Index. defaults to jena-text
+    text:entityMap <#entMap> ;
+    .
+
+<#entMap> a text:EntityMap ;
+    text:entityField      "uri" ; # Defines the Document Type in the ES Index
+    text:defaultField     "text" ; ## Must be defined in the text:maps
+    text:map (
+         # rdfs:label            
+         [ text:field "text" ; text:predicate rdfs:label ]
+         [ text:field "comment" ; text:predicate rdfs:comment ]
+         ) .

http://git-wip-us.apache.org/repos/asf/jena/blob/f56429fb/jena-text-es/src/test/java/org/apache/jena/query/text/es/it/BaseESTest.java
----------------------------------------------------------------------
diff --git a/jena-text-es/src/test/java/org/apache/jena/query/text/es/it/BaseESTest.java b/jena-text-es/src/test/java/org/apache/jena/query/text/es/it/BaseESTest.java
new file mode 100644
index 0000000..b76e62a
--- /dev/null
+++ b/jena-text-es/src/test/java/org/apache/jena/query/text/es/it/BaseESTest.java
@@ -0,0 +1,111 @@
+/**
+ * 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.es.it;
+
+import org.apache.jena.query.text.EntityDefinition;
+import org.apache.jena.query.text.TextIndexConfig;
+import org.apache.jena.query.text.es.TextIndexES;
+import org.apache.jena.vocabulary.RDFS;
+import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
+import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest;
+import org.elasticsearch.client.transport.TransportClient;
+import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.common.transport.InetSocketTransportAddress;
+import org.elasticsearch.transport.client.PreBuiltTransportClient;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+/**
+ * Base Class for ElasticSearch based Integration tests.
+ */
+public abstract class BaseESTest {
+
+    protected static TransportClient transportClient;
+
+    private final static String ADDRESS = "127.0.0.1";
+    private final static int PORT = 9500;
+    private final static String CLUSTER_NAME = "elasticsearch";
+    protected final static String INDEX_NAME = "jena-text";
+
+    protected static TextIndexES classToTest;
+
+    static final String DOC_TYPE = "text";
+
+    /**
+     * Make sure that we have connectivity to the locally running ES node.
+     * The ES is started during the pre-integration-test phase
+     */
+    @BeforeClass
+    public static void setupTransportClient() {
+
+        Settings settings = Settings.builder().put("cluster.name", CLUSTER_NAME).build();
+        transportClient = new PreBuiltTransportClient(settings);
+        try {
+            transportClient.addTransportAddress(
+                    new InetSocketTransportAddress(InetAddress.getByName(ADDRESS), PORT)
+            );
+        } catch (UnknownHostException ex) {
+            Assert.fail("Failed to create transport client" + ex.getMessage());
+        }
+        classToTest = new TextIndexES(config(), transportClient, INDEX_NAME);
+        Assert.assertNotNull("Transport client was not created successfully", transportClient);
+
+
+    }
+
+    /**
+     * Make sure that we always start we a clean index.
+     * This will help keep the tests isolated
+     * @throws Exception
+     */
+    @Before
+    public void beforeTest() throws Exception{
+        //Create Index
+        transportClient.admin().indices().prepareCreate(INDEX_NAME).get();
+        Assert.assertTrue(transportClient.admin().indices().exists(new IndicesExistsRequest(INDEX_NAME)).get().isExists());
+
+    }
+
+    /**
+     * Make sure that we always delete the index when completed with the test
+     * This will help keep the tests isolated
+     * @throws Exception
+     */
+    @After
+    public void afterTest() throws Exception{
+        //Delete Index
+        transportClient.admin().indices().delete(new DeleteIndexRequest(INDEX_NAME)).get();
+    }
+
+    /**
+     * Simple Config for text index
+     * @return
+     */
+    private static TextIndexConfig config() {
+        EntityDefinition ed = new EntityDefinition(DOC_TYPE, "label", RDFS.label);
+        ed.set("comment", RDFS.comment.asNode());
+        ed.setLangField("lang");
+        TextIndexConfig config = new TextIndexConfig(ed);
+        return config;
+    }
+}


Mime
View raw message