Bläddra i källkod

fix #2502 update boost values

Shinsuke Sugaya 4 år sedan
förälder
incheckning
c18f80a626

+ 14 - 12
src/main/java/org/codelibs/fess/helper/QueryHelper.java

@@ -687,19 +687,21 @@ public class QueryHelper {
     protected QueryBuilder buildDefaultQueryBuilder(final DefaultQueryBuilderFunction builder) {
         final BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
         final FessConfig fessConfig = ComponentUtil.getFessConfig();
-        final QueryBuilder titleQuery =
-                builder.apply(fessConfig.getIndexFieldTitle(), fessConfig.getQueryBoostTitleAsDecimal().floatValue());
-        boolQuery.should(titleQuery);
-        final QueryBuilder contentQuery =
-                builder.apply(fessConfig.getIndexFieldContent(), fessConfig.getQueryBoostContentAsDecimal().floatValue());
-        boolQuery.should(contentQuery);
+        boolQuery.should(builder.apply(fessConfig.getIndexFieldTitle(), fessConfig.getQueryBoostTitleAsDecimal().floatValue()));
+        boolQuery.should(builder.apply(fessConfig.getIndexFieldContent(), fessConfig.getQueryBoostContentAsDecimal().floatValue()));
+        final float importantContentBoost = fessConfig.getQueryBoostImportantContentAsDecimal().floatValue();
+        if (importantContentBoost >= 0.0f) {
+            boolQuery.should(builder.apply(fessConfig.getIndexFieldImportantContent(), importantContentBoost));
+        }
+        final float importantContantLangBoost = fessConfig.getQueryBoostImportantContentLangAsDecimal().floatValue();
         getQueryLanguages().ifPresent(langs -> stream(langs).of(stream -> stream.forEach(lang -> {
-            final QueryBuilder titleLangQuery =
-                    builder.apply(fessConfig.getIndexFieldTitle() + "_" + lang, fessConfig.getQueryBoostTitleLangAsDecimal().floatValue());
-            boolQuery.should(titleLangQuery);
-            final QueryBuilder contentLangQuery = builder.apply(fessConfig.getIndexFieldContent() + "_" + lang,
-                    fessConfig.getQueryBoostContentLangAsDecimal().floatValue());
-            boolQuery.should(contentLangQuery);
+            boolQuery.should(
+                    builder.apply(fessConfig.getIndexFieldTitle() + "_" + lang, fessConfig.getQueryBoostTitleLangAsDecimal().floatValue()));
+            boolQuery.should(builder.apply(fessConfig.getIndexFieldContent() + "_" + lang,
+                    fessConfig.getQueryBoostContentLangAsDecimal().floatValue()));
+            if (importantContantLangBoost >= 0.0f) {
+                boolQuery.should(builder.apply(fessConfig.getIndexFieldImportantContent() + "_" + lang, importantContantLangBoost));
+            }
         })));
         additionalDefaultList.stream().forEach(f -> {
             final QueryBuilder query = builder.apply(f.getFirst(), f.getSecond());

+ 66 - 12
src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java

@@ -926,18 +926,24 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
     */
     String QUERY_LANGUAGE_MAPPING = "query.language.mapping";
 
-    /** The key of the configuration. e.g. 0.01 */
+    /** The key of the configuration. e.g. 0.5 */
     String QUERY_BOOST_TITLE = "query.boost.title";
 
     /** The key of the configuration. e.g. 1.0 */
     String QUERY_BOOST_TITLE_LANG = "query.boost.title.lang";
 
-    /** The key of the configuration. e.g. 0.005 */
+    /** The key of the configuration. e.g. 0.05 */
     String QUERY_BOOST_CONTENT = "query.boost.content";
 
-    /** The key of the configuration. e.g. 0.5 */
+    /** The key of the configuration. e.g. 0.1 */
     String QUERY_BOOST_CONTENT_LANG = "query.boost.content.lang";
 
+    /** The key of the configuration. e.g. -1.0 */
+    String QUERY_BOOST_important_content = "query.boost.important_content";
+
+    /** The key of the configuration. e.g. -1.0 */
+    String QUERY_BOOST_important_content_LANG = "query.boost.important_content.lang";
+
     /** The key of the configuration. e.g. label */
     String QUERY_FACET_FIELDS = "query.facet.fields";
 
@@ -4261,7 +4267,7 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
 
     /**
      * Get the value for the key 'query.boost.title'. <br>
-     * The value is, e.g. 0.01 <br>
+     * The value is, e.g. 0.5 <br>
      * comment: boost
      * @return The value of found property. (NotNull: if not found, exception but basically no way)
      */
@@ -4269,7 +4275,7 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
 
     /**
      * Get the value for the key 'query.boost.title' as {@link java.math.BigDecimal}. <br>
-     * The value is, e.g. 0.01 <br>
+     * The value is, e.g. 0.5 <br>
      * comment: boost
      * @return The value of found property. (NotNull: if not found, exception but basically no way)
      * @throws NumberFormatException When the property is not decimal.
@@ -4293,14 +4299,14 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
 
     /**
      * Get the value for the key 'query.boost.content'. <br>
-     * The value is, e.g. 0.005 <br>
+     * The value is, e.g. 0.05 <br>
      * @return The value of found property. (NotNull: if not found, exception but basically no way)
      */
     String getQueryBoostContent();
 
     /**
      * Get the value for the key 'query.boost.content' as {@link java.math.BigDecimal}. <br>
-     * The value is, e.g. 0.005 <br>
+     * The value is, e.g. 0.05 <br>
      * @return The value of found property. (NotNull: if not found, exception but basically no way)
      * @throws NumberFormatException When the property is not decimal.
      */
@@ -4308,19 +4314,49 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
 
     /**
      * Get the value for the key 'query.boost.content.lang'. <br>
-     * The value is, e.g. 0.5 <br>
+     * The value is, e.g. 0.1 <br>
      * @return The value of found property. (NotNull: if not found, exception but basically no way)
      */
     String getQueryBoostContentLang();
 
     /**
      * Get the value for the key 'query.boost.content.lang' as {@link java.math.BigDecimal}. <br>
-     * The value is, e.g. 0.5 <br>
+     * The value is, e.g. 0.1 <br>
      * @return The value of found property. (NotNull: if not found, exception but basically no way)
      * @throws NumberFormatException When the property is not decimal.
      */
     java.math.BigDecimal getQueryBoostContentLangAsDecimal();
 
+    /**
+     * Get the value for the key 'query.boost.important_content'. <br>
+     * The value is, e.g. -1.0 <br>
+     * @return The value of found property. (NotNull: if not found, exception but basically no way)
+     */
+    String getQueryBoostImportantContent();
+
+    /**
+     * Get the value for the key 'query.boost.important_content' as {@link java.math.BigDecimal}. <br>
+     * The value is, e.g. -1.0 <br>
+     * @return The value of found property. (NotNull: if not found, exception but basically no way)
+     * @throws NumberFormatException When the property is not decimal.
+     */
+    java.math.BigDecimal getQueryBoostImportantContentAsDecimal();
+
+    /**
+     * Get the value for the key 'query.boost.important_content.lang'. <br>
+     * The value is, e.g. -1.0 <br>
+     * @return The value of found property. (NotNull: if not found, exception but basically no way)
+     */
+    String getQueryBoostImportantContentLang();
+
+    /**
+     * Get the value for the key 'query.boost.important_content.lang' as {@link java.math.BigDecimal}. <br>
+     * The value is, e.g. -1.0 <br>
+     * @return The value of found property. (NotNull: if not found, exception but basically no way)
+     * @throws NumberFormatException When the property is not decimal.
+     */
+    java.math.BigDecimal getQueryBoostImportantContentLangAsDecimal();
+
     /**
      * Get the value for the key 'query.facet.fields'. <br>
      * The value is, e.g. label <br>
@@ -7987,6 +8023,22 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
             return getAsDecimal(FessConfig.QUERY_BOOST_CONTENT_LANG);
         }
 
+        public String getQueryBoostImportantContent() {
+            return get(FessConfig.QUERY_BOOST_important_content);
+        }
+
+        public java.math.BigDecimal getQueryBoostImportantContentAsDecimal() {
+            return getAsDecimal(FessConfig.QUERY_BOOST_important_content);
+        }
+
+        public String getQueryBoostImportantContentLang() {
+            return get(FessConfig.QUERY_BOOST_important_content_LANG);
+        }
+
+        public java.math.BigDecimal getQueryBoostImportantContentLangAsDecimal() {
+            return getAsDecimal(FessConfig.QUERY_BOOST_important_content_LANG);
+        }
+
         public String getQueryFacetFields() {
             return get(FessConfig.QUERY_FACET_FIELDS);
         }
@@ -9480,10 +9532,12 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
             defaultMap.put(FessConfig.QUERY_GSA_DEFAULT_PREFERENCE, "_query");
             defaultMap.put(FessConfig.QUERY_LANGUAGE_MAPPING,
                     "ar=ar\nbg=bg\nbn=bn\nca=ca\nckb-iq=ckb-iq\nckb_IQ=ckb-iq\ncs=cs\nda=da\nde=de\nel=el\nen=en\nen-ie=en-ie\nen_IE=en-ie\nes=es\net=et\neu=eu\nfa=fa\nfi=fi\nfr=fr\ngl=gl\ngu=gu\nhe=he\nhi=hi\nhr=hr\nhu=hu\nhy=hy\nid=id\nit=it\nja=ja\nko=ko\nlt=lt\nlv=lv\nmk=mk\nml=ml\nnl=nl\nno=no\npa=pa\npl=pl\npt=pt\npt-br=pt-br\npt_BR=pt-br\nro=ro\nru=ru\nsi=si\nsq=sq\nsv=sv\nta=ta\nte=te\nth=th\ntl=tl\ntr=tr\nuk=uk\nur=ur\nvi=vi\nzh-cn=zh-cn\nzh_CN=zh-cn\nzh-tw=zh-tw\nzh_TW=zh-tw\nzh=zh\n");
-            defaultMap.put(FessConfig.QUERY_BOOST_TITLE, "0.01");
+            defaultMap.put(FessConfig.QUERY_BOOST_TITLE, "0.5");
             defaultMap.put(FessConfig.QUERY_BOOST_TITLE_LANG, "1.0");
-            defaultMap.put(FessConfig.QUERY_BOOST_CONTENT, "0.005");
-            defaultMap.put(FessConfig.QUERY_BOOST_CONTENT_LANG, "0.5");
+            defaultMap.put(FessConfig.QUERY_BOOST_CONTENT, "0.05");
+            defaultMap.put(FessConfig.QUERY_BOOST_CONTENT_LANG, "0.1");
+            defaultMap.put(FessConfig.QUERY_BOOST_important_content, "-1.0");
+            defaultMap.put(FessConfig.QUERY_BOOST_important_content_LANG, "-1.0");
             defaultMap.put(FessConfig.QUERY_FACET_FIELDS, "label");
             defaultMap.put(FessConfig.QUERY_FACET_FIELDS_SIZE, "100");
             defaultMap.put(FessConfig.QUERY_FACET_FIELDS_min_doc_count, "1");

+ 5 - 3
src/main/resources/fess_config.properties

@@ -506,10 +506,12 @@ zh_TW=zh-tw\n\
 zh=zh\n\
 
 # boost
-query.boost.title=0.01
+query.boost.title=0.5
 query.boost.title.lang=1.0
-query.boost.content=0.005
-query.boost.content.lang=0.5
+query.boost.content=0.05
+query.boost.content.lang=0.1
+query.boost.important_content=-1.0
+query.boost.important_content.lang=-1.0
 
 # facet
 query.facet.fields=label

+ 3 - 1
src/main/resources/fess_indices/fess/doc.json

@@ -493,7 +493,9 @@
       },
       "important_content": {
         "type": "text",
-        "index": false
+        "analyzer": "standard_analyzer",
+        "search_analyzer": "standard_search_analyzer",
+        "term_vector": "with_positions_offsets"
       },
       "content": {
         "type": "text",