ソースを参照

fix #1226 add query.gsa.response.fields

Shinsuke Sugaya 8 年 前
コミット
b552e57fe1

+ 4 - 3
src/main/java/org/codelibs/fess/api/gsa/GsaApiManager.java

@@ -221,10 +221,11 @@ public class GsaApiManager extends BaseApiManager implements WebApiManager {
                     }
                     }
                     for (final Map.Entry<String, Object> entry : document.entrySet()) {
                     for (final Map.Entry<String, Object> entry : document.entrySet()) {
                         final String name = entry.getKey();
                         final String name = entry.getKey();
-                        if (StringUtil.isNotBlank(name) && entry.getValue() != null
-                                && ComponentUtil.getQueryHelper().isApiResponseField(name)) {
+                        if (StringUtil.isNotBlank(name) && entry.getValue() != null && fessConfig.isGsaResponseFields(name)) {
                             if (name.startsWith(gsaMetaPrefix)) {
                             if (name.startsWith(gsaMetaPrefix)) {
-                                final String tagName = name.replaceAll("^" + gsaMetaPrefix, "").replaceAll(GSA_META_SUFFIX + "\\z", "");
+                                final String tagName =
+                                        name.replaceFirst("^" + gsaMetaPrefix, StringUtil.EMPTY).replaceAll(GSA_META_SUFFIX + "\\z",
+                                                StringUtil.EMPTY);
                                 if (getFields != null && getFields.contains(tagName)) {
                                 if (getFields != null && getFields.contains(tagName)) {
                                     buf.append("<MT N=\"");
                                     buf.append("<MT N=\"");
                                     buf.append(tagName);
                                     buf.append(tagName);

+ 15 - 0
src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java

@@ -525,6 +525,9 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
     /** The key of the configuration. e.g.  */
     /** The key of the configuration. e.g.  */
     String QUERY_ADDITIONAL_NOT_ANALYZED_FIELDS = "query.additional.not.analyzed.fields";
     String QUERY_ADDITIONAL_NOT_ANALYZED_FIELDS = "query.additional.not.analyzed.fields";
 
 
+    /** The key of the configuration. e.g. UE,U,T,RK,S,LANG */
+    String QUERY_GSA_RESPONSE_FIELDS = "query.gsa.response.fields";
+
     /** The key of the configuration. e.g. 4 */
     /** The key of the configuration. e.g. 4 */
     String QUERY_COLLAPSE_MAX_CONCURRENT_GROUP_RESULTS = "query.collapse.max.concurrent.group.results";
     String QUERY_COLLAPSE_MAX_CONCURRENT_GROUP_RESULTS = "query.collapse.max.concurrent.group.results";
 
 
@@ -2866,6 +2869,13 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
      */
      */
     Integer getQueryAdditionalNotAnalyzedFieldsAsInteger();
     Integer getQueryAdditionalNotAnalyzedFieldsAsInteger();
 
 
+    /**
+     * Get the value for the key 'query.gsa.response.fields'. <br>
+     * The value is, e.g. UE,U,T,RK,S,LANG <br>
+     * @return The value of found property. (NotNull: if not found, exception but basically no way)
+     */
+    String getQueryGsaResponseFields();
+
     /**
     /**
      * Get the value for the key 'query.collapse.max.concurrent.group.results'. <br>
      * Get the value for the key 'query.collapse.max.concurrent.group.results'. <br>
      * The value is, e.g. 4 <br>
      * The value is, e.g. 4 <br>
@@ -6143,6 +6153,10 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
             return getAsInteger(FessConfig.QUERY_ADDITIONAL_NOT_ANALYZED_FIELDS);
             return getAsInteger(FessConfig.QUERY_ADDITIONAL_NOT_ANALYZED_FIELDS);
         }
         }
 
 
+        public String getQueryGsaResponseFields() {
+            return get(FessConfig.QUERY_GSA_RESPONSE_FIELDS);
+        }
+
         public String getQueryCollapseMaxConcurrentGroupResults() {
         public String getQueryCollapseMaxConcurrentGroupResults() {
             return get(FessConfig.QUERY_COLLAPSE_MAX_CONCURRENT_GROUP_RESULTS);
             return get(FessConfig.QUERY_COLLAPSE_MAX_CONCURRENT_GROUP_RESULTS);
         }
         }
@@ -7593,6 +7607,7 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
             defaultMap.put(FessConfig.QUERY_ADDITIONAL_FACET_FIELDS, "");
             defaultMap.put(FessConfig.QUERY_ADDITIONAL_FACET_FIELDS, "");
             defaultMap.put(FessConfig.QUERY_ADDITIONAL_SORT_FIELDS, "");
             defaultMap.put(FessConfig.QUERY_ADDITIONAL_SORT_FIELDS, "");
             defaultMap.put(FessConfig.QUERY_ADDITIONAL_NOT_ANALYZED_FIELDS, "");
             defaultMap.put(FessConfig.QUERY_ADDITIONAL_NOT_ANALYZED_FIELDS, "");
+            defaultMap.put(FessConfig.QUERY_GSA_RESPONSE_FIELDS, "UE,U,T,RK,S,LANG");
             defaultMap.put(FessConfig.QUERY_COLLAPSE_MAX_CONCURRENT_GROUP_RESULTS, "4");
             defaultMap.put(FessConfig.QUERY_COLLAPSE_MAX_CONCURRENT_GROUP_RESULTS, "4");
             defaultMap.put(FessConfig.QUERY_COLLAPSE_INNER_HITS_NAME, "similar_docs");
             defaultMap.put(FessConfig.QUERY_COLLAPSE_INNER_HITS_NAME, "similar_docs");
             defaultMap.put(FessConfig.QUERY_COLLAPSE_INNER_HITS_SIZE, "0");
             defaultMap.put(FessConfig.QUERY_COLLAPSE_INNER_HITS_SIZE, "0");

+ 17 - 0
src/main/java/org/codelibs/fess/mylasta/direction/FessProp.java

@@ -71,6 +71,8 @@ import org.lastaflute.web.validation.theme.typed.LongTypeValidator;
 
 
 public interface FessProp {
 public interface FessProp {
 
 
+    public static final String QUERY_GSA_RESPONSE_FIELDS = "queryGsaResponseFields";
+
     public static final String THUMBNAIL_HTML_IMAGE_EXCLUDE_EXTENSIONS = "ThumbnailHtmlImageExcludeExtensions";
     public static final String THUMBNAIL_HTML_IMAGE_EXCLUDE_EXTENSIONS = "ThumbnailHtmlImageExcludeExtensions";
 
 
     public static final String VIRTUAL_HOST_VALUE = "VirtualHostValue";
     public static final String VIRTUAL_HOST_VALUE = "VirtualHostValue";
@@ -1771,4 +1773,19 @@ public interface FessProp {
         return !stream(excludeExtensions).get(stream -> stream.anyMatch(s -> u.endsWith(s)));
         return !stream(excludeExtensions).get(stream -> stream.anyMatch(s -> u.endsWith(s)));
     }
     }
 
 
+    String getQueryGsaResponseFields();
+
+    public default boolean isGsaResponseFields(final String name) {
+        @SuppressWarnings("unchecked")
+        Set<String> gsaResponseFieldSet = (Set<String>) propMap.get(QUERY_GSA_RESPONSE_FIELDS);
+        if (gsaResponseFieldSet == null) {
+            gsaResponseFieldSet =
+                    split(getQueryGsaResponseFields(), ",").get(
+                            stream -> stream.map(s -> s.toLowerCase(Locale.ROOT).trim()).filter(StringUtil::isNotBlank)
+                                    .collect(Collectors.toSet()));
+            propMap.put(QUERY_GSA_RESPONSE_FIELDS, gsaResponseFieldSet);
+        }
+        return gsaResponseFieldSet.contains(name.toLowerCase(Locale.ROOT));
+    }
+
 }
 }

+ 1 - 0
src/main/resources/fess_config.properties

@@ -238,6 +238,7 @@ query.additional.search.fields=
 query.additional.facet.fields=
 query.additional.facet.fields=
 query.additional.sort.fields=
 query.additional.sort.fields=
 query.additional.not.analyzed.fields=
 query.additional.not.analyzed.fields=
+query.gsa.response.fields=UE,U,T,RK,S,LANG
 query.collapse.max.concurrent.group.results=4
 query.collapse.max.concurrent.group.results=4
 query.collapse.inner.hits.name=similar_docs
 query.collapse.inner.hits.name=similar_docs
 query.collapse.inner.hits.size=0
 query.collapse.inner.hits.size=0