You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2024/02/08 21:45:39 UTC

(jena) 03/03: GH-2094: Remove duplicate query expressions

This is an automated email from the ASF dual-hosted git repository.

andy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/jena.git

commit cb53d3d104250be0e2f3ae3c178cda22bfccd651
Author: Øyvind Gjesdal <oy...@uib.no>
AuthorDate: Wed Dec 20 22:07:30 2023 +0100

    GH-2094: Remove duplicate query expressions
---
 .../src/main/java/org/apache/jena/query/text/TextIndexLucene.java  | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/jena-text/src/main/java/org/apache/jena/query/text/TextIndexLucene.java b/jena-text/src/main/java/org/apache/jena/query/text/TextIndexLucene.java
index 15587a2e57..1e181007b4 100644
--- a/jena-text/src/main/java/org/apache/jena/query/text/TextIndexLucene.java
+++ b/jena-text/src/main/java/org/apache/jena/query/text/TextIndexLucene.java
@@ -723,6 +723,10 @@ public class TextIndexLucene implements TextIndex {
         List<String> searchForTags = Util.getSearchForTags(lang);
         boolean usingSearchFor = Util.usingSearchFor(lang);
 
+        // The set will reduce lucene text field expressions
+        // to unique expressions
+        Set<String> uniquePropListQueryStrings = new LinkedHashSet<>();
+
         if (props.isEmpty()) {
             // we got here via
             //    ?s text:query "some query string"
@@ -746,8 +750,9 @@ public class TextIndexLucene implements TextIndex {
 
         log.trace("query$ PROCESSING LIST of properties: {}; Lucene queryString: {}; textFields: {} ", props, qString, textFields) ;
         for (String textField : textFields) {
-            qString += composeQField(qs, textField, lang, usingSearchFor, searchForTags);
+            uniquePropListQueryStrings.add(composeQField(qs, textField, lang, usingSearchFor, searchForTags));
         }
+        qString += String.join("", uniquePropListQueryStrings);
 
         // we need to check whether there was a lang arg either on the query string
         // or explicitly as an input arg and add it to the qString; otherwise, Lucene