[
https://issues.apache.org/jira/browse/JENA-1532?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16450128#comment-16450128
]
ASF GitHub Bot commented on JENA-1532:
--------------------------------------
Github user afs commented on a diff in the pull request:
https://github.com/apache/jena/pull/406#discussion_r183788841
--- Diff:
jena-text-es/src/main/java/org/apache/jena/query/text/es/TextIndexES.java ---
@@ -422,6 +422,27 @@ public EntityDefinition getDocDef() {
}
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("\\?", "\\\\?");
+
--- End diff --
The [Lucene escape
code|https://github.com/apache/lucene-solr/blob/master/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParserBase.java#L971].
It includes `\\` and does a simple pass over the string.
The thing to watch for with `replaceAll` is that it creates a regex every
call which can mount up even for these fixed string regexps.
> Jena Text Elastic Search Does not perform proper date comparison during query
> -----------------------------------------------------------------------------
>
> Key: JENA-1532
> URL: https://issues.apache.org/jira/browse/JENA-1532
> Project: Apache Jena
> Issue Type: Bug
> Components: Text
> Affects Versions: Jena 3.7.0
> Reporter: Anuj Kumar
> Priority: Major
>
> Jena Text Elastic Search is an implementation of the text query capability of
> Jena to perform text based searching and Filtering of data. It uses [Query
> String
> Query|https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html]
> capability of elastic search to perform searches.
> We found a bug in the implementation where searching on date values does not
> work properly. For example, if we have a following text query:
> {code:java}
> SELECT ?s { ?s text:query ('2016-12-01T15:31:10-05:00') ;{code}
> then the implementation threw exception because there are unescaped ":"
> (colon) in the value. Since ":" is a reserved character in the Query String
> Query capability of Elastic search, we have to escape the character.
>
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)