jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [3/9] jena git commit: JENA-1532 | fix for date based text query search
Date Fri, 04 May 2018 08:40:44 GMT
JENA-1532 | fix for date based text query search


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

Branch: refs/heads/master
Commit: 77058de86a6a85f6bdffc5b0b733572cac1d84b1
Parents: 7f4915e
Author: Anuj Kumar <akumar1@isightpartners.com>
Authored: Tue Apr 24 19:38:37 2018 +0200
Committer: Anuj Kumar <akumar1@isightpartners.com>
Committed: Tue Apr 24 19:38:37 2018 +0200

----------------------------------------------------------------------
 .../apache/jena/query/text/es/TextIndexES.java  | 21 ++------------------
 .../jena/query/text/es/it/TextIndexESIT.java    |  9 +++++++++
 2 files changed, 11 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/77058de8/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
index 6a8a649..62c66f3 100644
--- 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
@@ -23,6 +23,7 @@ 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.apache.lucene.queryparser.classic.QueryParserBase;
 import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest;
 import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse;
 import org.elasticsearch.action.get.GetResponse;
@@ -423,25 +424,7 @@ public class TextIndexES implements TextIndex {
 
     private String parse(String fieldName, String qs, String lang) {
         //Escape special characters if any in the query string
-        qs = qs.replaceAll("\\:", "\\\\:")
-                .replaceAll("\\+", "\\\\+")
-                .replaceAll("\\-", "\\\\-")
-                .replaceAll("\\=", "\\\\=")
-                .replaceAll("\\&", "\\\\&")
-                .replaceAll("\\|", "\\\\|")
-                .replaceAll("\\>", "\\\\>")
-                .replaceAll("\\<", "\\\\<")
-                .replaceAll("\\!", "\\\\!")
-                .replaceAll("\\(", "\\\\(")
-                .replaceAll("\\)", "\\\\)")
-                .replaceAll("\\{", "\\\\{")
-                .replaceAll("\\}", "\\\\}")
-                .replaceAll("\\]", "\\\\]")
-                .replaceAll("\\[", "\\\\[")
-                .replaceAll("\\^", "\\\\^")
-                .replaceAll("\\~", "\\\\~")
-                .replaceAll("\\?", "\\\\?");
-
+        qs = QueryParserBase.escape(qs);
 
         if(fieldName != null && !fieldName.isEmpty()) {
             if(lang != null && !lang.equals("none")) {

http://git-wip-us.apache.org/repos/asf/jena/blob/77058de8/jena-text-es/src/test/java/org/apache/jena/query/text/es/it/TextIndexESIT.java
----------------------------------------------------------------------
diff --git a/jena-text-es/src/test/java/org/apache/jena/query/text/es/it/TextIndexESIT.java
b/jena-text-es/src/test/java/org/apache/jena/query/text/es/it/TextIndexESIT.java
index 1e03e39..022bef5 100644
--- a/jena-text-es/src/test/java/org/apache/jena/query/text/es/it/TextIndexESIT.java
+++ b/jena-text-es/src/test/java/org/apache/jena/query/text/es/it/TextIndexESIT.java
@@ -240,6 +240,15 @@ public class TextIndexESIT extends BaseESTest {
 
     }
 
+    @Test
+    public void testBackslash() {
+        addSpecialCharacterString("label", "C:\\ title.csv save this");
+        String queryString = "C:\\ title.csv";
+        querySpecialCharacterQuery(RDFS.label.asNode(), queryString, null, 10, 1);
+        querySpecialCharacterQuery(null, queryString, null, 10, 1);
+        querySpecialCharacterQuery(RDFS.label.asNode(), queryString, "en", 10, 1);
+    }
+
 
     private void addSpecialCharacterString(String key, String value) {
 


Mime
View raw message