You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by fo...@apache.org on 2022/02/18 13:26:18 UTC

[jackrabbit-oak] branch FrancoisZhang-OAK-9696 created (now 7646101)

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

fortino pushed a change to branch FrancoisZhang-OAK-9696
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git.


      at 7646101  simplified addDynamicBoostField

This branch includes the following new commits:

     new 7646101  simplified addDynamicBoostField

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[jackrabbit-oak] 01/01: simplified addDynamicBoostField

Posted by fo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

fortino pushed a commit to branch FrancoisZhang-OAK-9696
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git

commit 76461010bab03b0fbb5a5e30e74f522e865d6cdf
Author: fabriziofortino <fa...@gmail.com>
AuthorDate: Fri Feb 18 14:22:46 2022 +0100

    simplified addDynamicBoostField
---
 .../index/elastic/index/ElasticDocument.java       | 24 +++++++++++-----------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/index/ElasticDocument.java b/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/index/ElasticDocument.java
index f272588..92ff2c3 100644
--- a/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/index/ElasticDocument.java
+++ b/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/index/ElasticDocument.java
@@ -100,6 +100,8 @@ public class ElasticDocument {
     void addDynamicBoostField(String propName, String value, double boost) {
         dynamicBoostFields.computeIfAbsent(propName, s -> new HashMap<>())
                 .putIfAbsent(value, boost);
+        // also add into fulltext field so lucene query syntax can be used against boosted terms
+        addFulltext(value);
     }
 
     void addSimilarityTag(String value) {
@@ -113,18 +115,6 @@ public class ElasticDocument {
             builder.startObject();
             {
                 builder.field(FieldNames.PATH, path);
-                for (Map.Entry<String, Map<String, Double>> f : dynamicBoostFields.entrySet()) {
-                    builder.startArray(f.getKey());
-                    for (Map.Entry<String, Double> v : f.getValue().entrySet()) {
-                        builder.startObject();
-                        builder.field("value", v.getKey());
-                        builder.field("boost", v.getValue());
-                        builder.endObject();
-                        // also add into fulltext field
-                        addFulltext(v.getKey());
-                    }
-                    builder.endArray();
-                }
                 if (fulltext.size() > 0) {
                     builder.field(FieldNames.FULLTEXT, fulltext);
                 }
@@ -144,6 +134,16 @@ public class ElasticDocument {
                 for (Map.Entry<String, List<Object>> prop : properties.entrySet()) {
                     builder.field(prop.getKey(), prop.getValue().size() == 1 ? prop.getValue().get(0) : prop.getValue());
                 }
+                for (Map.Entry<String, Map<String, Double>> f : dynamicBoostFields.entrySet()) {
+                    builder.startArray(f.getKey());
+                    for (Map.Entry<String, Double> v : f.getValue().entrySet()) {
+                        builder.startObject();
+                        builder.field("value", v.getKey());
+                        builder.field("boost", v.getValue());
+                        builder.endObject();
+                    }
+                    builder.endArray();
+                }
                 if (!similarityTags.isEmpty()) {
                     builder.field(ElasticIndexDefinition.SIMILARITY_TAGS, similarityTags);
                 }