diff --git a/src/main/java/org/codelibs/fess/helper/QueryHelper.java b/src/main/java/org/codelibs/fess/helper/QueryHelper.java index 0ab2aa6d7..7b20827ea 100644 --- a/src/main/java/org/codelibs/fess/helper/QueryHelper.java +++ b/src/main/java/org/codelibs/fess/helper/QueryHelper.java @@ -99,8 +99,6 @@ public class QueryHelper { protected String[] cacheResponseFields; - protected String[] responseDocValuesFields; - protected String[] highlightedFields; protected String[] searchFields; @@ -109,7 +107,7 @@ public class QueryHelper { protected String sortPrefix = "sort:"; - protected String[] supportedSortFields; + protected String[] sortFields; protected int highlightFragmentSize = 100; @@ -138,7 +136,8 @@ public class QueryHelper { @PostConstruct public void init() { if (responseFields == null) { - responseFields = new String[] { SCORE_FIELD, // + responseFields = fessConfig.getQueryAdditionalResponseFields(// + SCORE_FIELD, // fessConfig.getIndexFieldId(), // fessConfig.getIndexFieldDocId(), // fessConfig.getIndexFieldBoost(), // @@ -158,10 +157,11 @@ public class QueryHelper { fessConfig.getIndexFieldFavoriteCount(), // fessConfig.getIndexFieldConfigId(), // fessConfig.getIndexFieldLang(), // - fessConfig.getIndexFieldHasCache() }; + fessConfig.getIndexFieldHasCache()); } if (cacheResponseFields == null) { - cacheResponseFields = new String[] { SCORE_FIELD, // + cacheResponseFields = fessConfig.getQueryAdditionalCacheResponseFields(// + SCORE_FIELD, // fessConfig.getIndexFieldId(), // fessConfig.getIndexFieldDocId(), // fessConfig.getIndexFieldBoost(), // @@ -181,18 +181,14 @@ public class QueryHelper { fessConfig.getIndexFieldFavoriteCount(), // fessConfig.getIndexFieldConfigId(), // fessConfig.getIndexFieldLang(), // - fessConfig.getIndexFieldCache() }; - } - if (responseDocValuesFields == null) { - responseDocValuesFields = new String[] {// - fessConfig.getIndexFieldClickCount(), // - fessConfig.getIndexFieldFavoriteCount() }; + fessConfig.getIndexFieldCache()); } if (highlightedFields == null) { - highlightedFields = new String[] { fessConfig.getIndexFieldContent() }; + highlightedFields = fessConfig.getQueryAdditionalHighlightedFields(fessConfig.getIndexFieldContent()); } if (searchFields == null) { - searchFields = new String[] { INURL_FIELD, // + searchFields = fessConfig.getQueryAdditionalSearchFields(// + INURL_FIELD, // fessConfig.getIndexFieldUrl(), // fessConfig.getIndexFieldDocId(), // fessConfig.getIndexFieldHost(), // @@ -208,35 +204,36 @@ public class QueryHelper { fessConfig.getIndexFieldSegment(), // fessConfig.getIndexFieldClickCount(), // fessConfig.getIndexFieldFavoriteCount(), // - fessConfig.getIndexFieldLang() }; + fessConfig.getIndexFieldLang()); } if (facetFields == null) { - facetFields = new String[] {// + facetFields = fessConfig.getQueryAdditionalFacetFields(// fessConfig.getIndexFieldUrl(), // - fessConfig.getIndexFieldHost(), // - fessConfig.getIndexFieldTitle(), // - fessConfig.getIndexFieldContent(), // - fessConfig.getIndexFieldContentLength(), // - fessConfig.getIndexFieldLastModified(), // - fessConfig.getIndexFieldTimestamp(), // - fessConfig.getIndexFieldMimetype(), // - fessConfig.getIndexFieldFiletype(), // - fessConfig.getIndexFieldLabel(), // - fessConfig.getIndexFieldSegment() }; + fessConfig.getIndexFieldHost(), // + fessConfig.getIndexFieldTitle(), // + fessConfig.getIndexFieldContent(), // + fessConfig.getIndexFieldContentLength(), // + fessConfig.getIndexFieldLastModified(), // + fessConfig.getIndexFieldTimestamp(), // + fessConfig.getIndexFieldMimetype(), // + fessConfig.getIndexFieldFiletype(), // + fessConfig.getIndexFieldLabel(), // + fessConfig.getIndexFieldSegment()); } - if (supportedSortFields == null) { - supportedSortFields = new String[] { SCORE_SORT_VALUE, // + if (sortFields == null) { + sortFields = fessConfig.getQueryAdditionalSortFields(// + SCORE_SORT_VALUE, // fessConfig.getIndexFieldFilename(), // fessConfig.getIndexFieldCreated(), // fessConfig.getIndexFieldContentLength(), // fessConfig.getIndexFieldLastModified(), // fessConfig.getIndexFieldTimestamp(), // fessConfig.getIndexFieldClickCount(), // - fessConfig.getIndexFieldFavoriteCount() }; + fessConfig.getIndexFieldFavoriteCount()); } if (apiResponseFieldSet == null) { - setApiResponseFields(new String[] {// - fessConfig.getResponseFieldContentDescription(), // + setApiResponseFields(fessConfig.getQueryAdditionalApiResponseFields(// + fessConfig.getResponseFieldContentDescription(), // fessConfig.getResponseFieldContentTitle(), // fessConfig.getResponseFieldSitePath(), // fessConfig.getResponseFieldUrlLink(), // @@ -254,11 +251,11 @@ public class QueryHelper { fessConfig.getIndexFieldCreated(), // fessConfig.getIndexFieldTitle(), // fessConfig.getIndexFieldDigest(), // - fessConfig.getIndexFieldUrl() }); + fessConfig.getIndexFieldUrl())); } if (notAnalyzedFieldSet == null) { - setNotAnalyzedFields(new String[] {// - fessConfig.getIndexFieldAnchor(), // + setNotAnalyzedFields(fessConfig.getQueryAdditionalNotAnalyzedFields(// + fessConfig.getIndexFieldAnchor(), // fessConfig.getIndexFieldBoost(), // fessConfig.getIndexFieldClickCount(), // fessConfig.getIndexFieldConfigId(), // @@ -282,7 +279,7 @@ public class QueryHelper { fessConfig.getIndexFieldSite(), // fessConfig.getIndexFieldTimestamp(), // fessConfig.getIndexFieldUrl(), // - fessConfig.getIndexFieldVersion() }); + fessConfig.getIndexFieldVersion())); } } @@ -603,7 +600,7 @@ public class QueryHelper { } private boolean isSortField(final String field) { - for (final String f : supportedSortFields) { + for (final String f : sortFields) { if (f.equals(field)) { return true; } @@ -668,14 +665,6 @@ public class QueryHelper { this.cacheResponseFields = cacheResponseFields; } - public String[] getResponseDocValuesFields() { - return responseDocValuesFields; - } - - public void setResponseDocValuesFields(final String[] responseDocValuesFields) { - this.responseDocValuesFields = responseDocValuesFields; - } - /** * @return the highlightedFields */ @@ -738,17 +727,17 @@ public class QueryHelper { } /** - * @return the supportedSortFields + * @return the sortFields */ - public String[] getSupportedSortFields() { - return supportedSortFields; + public String[] getSortFields() { + return sortFields; } /** - * @param supportedSortFields the supportedSortFields to set + * @param sortFields the sortFields to set */ - public void setSupportedSortFields(final String[] supportedSortFields) { - this.supportedSortFields = supportedSortFields; + public void setSortFields(final String[] supportedSortFields) { + this.sortFields = supportedSortFields; } public void addHighlightField(final String field) { diff --git a/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java b/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java index 0047f5977..44e0f15eb 100644 --- a/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java +++ b/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java @@ -415,6 +415,30 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction /** The key of the configuration. e.g. true */ String QUERY_REPLACE_TERM_WITH_PREFIX_QUERY = "query.replace.term.with.prefix.query"; + /** The key of the configuration. e.g. */ + String QUERY_ADDITIONAL_RESPONSE_FIELDS = "query.additional.response.fields"; + + /** The key of the configuration. e.g. */ + String QUERY_ADDITIONAL_API_RESPONSE_FIELDS = "query.additional.api.response.fields"; + + /** The key of the configuration. e.g. */ + String QUERY_ADDITIONAL_CACHE_RESPONSE_FIELDS = "query.additional.cache.response.fields"; + + /** The key of the configuration. e.g. */ + String QUERY_ADDITIONAL_HIGHLIGHTED_FIELDS = "query.additional.highlighted.fields"; + + /** The key of the configuration. e.g. */ + String QUERY_ADDITIONAL_SEARCH_FIELDS = "query.additional.search.fields"; + + /** The key of the configuration. e.g. */ + String QUERY_ADDITIONAL_FACET_FIELDS = "query.additional.facet.fields"; + + /** The key of the configuration. e.g. */ + String QUERY_ADDITIONAL_SORT_FIELDS = "query.additional.sort.fields"; + + /** The key of the configuration. e.g. */ + String QUERY_ADDITIONAL_NOT_ANALYZED_FIELDS = "query.additional.not.analyzed.fields"; + /** The key of the configuration. e.g. */ String QUERY_DEFAULT_LANGUAGES = "query.default.languages"; @@ -2206,6 +2230,126 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction */ boolean isQueryReplaceTermWithPrefixQuery(); + /** + * Get the value for the key 'query.additional.response.fields'.
+ * The value is, e.g.
+ * @return The value of found property. (NotNull: if not found, exception but basically no way) + */ + String getQueryAdditionalResponseFields(); + + /** + * Get the value for the key 'query.additional.response.fields' as {@link Integer}.
+ * The value is, e.g.
+ * @return The value of found property. (NotNull: if not found, exception but basically no way) + * @throws NumberFormatException When the property is not integer. + */ + Integer getQueryAdditionalResponseFieldsAsInteger(); + + /** + * Get the value for the key 'query.additional.api.response.fields'.
+ * The value is, e.g.
+ * @return The value of found property. (NotNull: if not found, exception but basically no way) + */ + String getQueryAdditionalApiResponseFields(); + + /** + * Get the value for the key 'query.additional.api.response.fields' as {@link Integer}.
+ * The value is, e.g.
+ * @return The value of found property. (NotNull: if not found, exception but basically no way) + * @throws NumberFormatException When the property is not integer. + */ + Integer getQueryAdditionalApiResponseFieldsAsInteger(); + + /** + * Get the value for the key 'query.additional.cache.response.fields'.
+ * The value is, e.g.
+ * @return The value of found property. (NotNull: if not found, exception but basically no way) + */ + String getQueryAdditionalCacheResponseFields(); + + /** + * Get the value for the key 'query.additional.cache.response.fields' as {@link Integer}.
+ * The value is, e.g.
+ * @return The value of found property. (NotNull: if not found, exception but basically no way) + * @throws NumberFormatException When the property is not integer. + */ + Integer getQueryAdditionalCacheResponseFieldsAsInteger(); + + /** + * Get the value for the key 'query.additional.highlighted.fields'.
+ * The value is, e.g.
+ * @return The value of found property. (NotNull: if not found, exception but basically no way) + */ + String getQueryAdditionalHighlightedFields(); + + /** + * Get the value for the key 'query.additional.highlighted.fields' as {@link Integer}.
+ * The value is, e.g.
+ * @return The value of found property. (NotNull: if not found, exception but basically no way) + * @throws NumberFormatException When the property is not integer. + */ + Integer getQueryAdditionalHighlightedFieldsAsInteger(); + + /** + * Get the value for the key 'query.additional.search.fields'.
+ * The value is, e.g.
+ * @return The value of found property. (NotNull: if not found, exception but basically no way) + */ + String getQueryAdditionalSearchFields(); + + /** + * Get the value for the key 'query.additional.search.fields' as {@link Integer}.
+ * The value is, e.g.
+ * @return The value of found property. (NotNull: if not found, exception but basically no way) + * @throws NumberFormatException When the property is not integer. + */ + Integer getQueryAdditionalSearchFieldsAsInteger(); + + /** + * Get the value for the key 'query.additional.facet.fields'.
+ * The value is, e.g.
+ * @return The value of found property. (NotNull: if not found, exception but basically no way) + */ + String getQueryAdditionalFacetFields(); + + /** + * Get the value for the key 'query.additional.facet.fields' as {@link Integer}.
+ * The value is, e.g.
+ * @return The value of found property. (NotNull: if not found, exception but basically no way) + * @throws NumberFormatException When the property is not integer. + */ + Integer getQueryAdditionalFacetFieldsAsInteger(); + + /** + * Get the value for the key 'query.additional.sort.fields'.
+ * The value is, e.g.
+ * @return The value of found property. (NotNull: if not found, exception but basically no way) + */ + String getQueryAdditionalSortFields(); + + /** + * Get the value for the key 'query.additional.sort.fields' as {@link Integer}.
+ * The value is, e.g.
+ * @return The value of found property. (NotNull: if not found, exception but basically no way) + * @throws NumberFormatException When the property is not integer. + */ + Integer getQueryAdditionalSortFieldsAsInteger(); + + /** + * Get the value for the key 'query.additional.not.analyzed.fields'.
+ * The value is, e.g.
+ * @return The value of found property. (NotNull: if not found, exception but basically no way) + */ + String getQueryAdditionalNotAnalyzedFields(); + + /** + * Get the value for the key 'query.additional.not.analyzed.fields' as {@link Integer}.
+ * The value is, e.g.
+ * @return The value of found property. (NotNull: if not found, exception but basically no way) + * @throws NumberFormatException When the property is not integer. + */ + Integer getQueryAdditionalNotAnalyzedFieldsAsInteger(); + /** * Get the value for the key 'query.default.languages'.
* The value is, e.g.
@@ -4784,6 +4928,70 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction return is(FessConfig.QUERY_REPLACE_TERM_WITH_PREFIX_QUERY); } + public String getQueryAdditionalResponseFields() { + return get(FessConfig.QUERY_ADDITIONAL_RESPONSE_FIELDS); + } + + public Integer getQueryAdditionalResponseFieldsAsInteger() { + return getAsInteger(FessConfig.QUERY_ADDITIONAL_RESPONSE_FIELDS); + } + + public String getQueryAdditionalApiResponseFields() { + return get(FessConfig.QUERY_ADDITIONAL_API_RESPONSE_FIELDS); + } + + public Integer getQueryAdditionalApiResponseFieldsAsInteger() { + return getAsInteger(FessConfig.QUERY_ADDITIONAL_API_RESPONSE_FIELDS); + } + + public String getQueryAdditionalCacheResponseFields() { + return get(FessConfig.QUERY_ADDITIONAL_CACHE_RESPONSE_FIELDS); + } + + public Integer getQueryAdditionalCacheResponseFieldsAsInteger() { + return getAsInteger(FessConfig.QUERY_ADDITIONAL_CACHE_RESPONSE_FIELDS); + } + + public String getQueryAdditionalHighlightedFields() { + return get(FessConfig.QUERY_ADDITIONAL_HIGHLIGHTED_FIELDS); + } + + public Integer getQueryAdditionalHighlightedFieldsAsInteger() { + return getAsInteger(FessConfig.QUERY_ADDITIONAL_HIGHLIGHTED_FIELDS); + } + + public String getQueryAdditionalSearchFields() { + return get(FessConfig.QUERY_ADDITIONAL_SEARCH_FIELDS); + } + + public Integer getQueryAdditionalSearchFieldsAsInteger() { + return getAsInteger(FessConfig.QUERY_ADDITIONAL_SEARCH_FIELDS); + } + + public String getQueryAdditionalFacetFields() { + return get(FessConfig.QUERY_ADDITIONAL_FACET_FIELDS); + } + + public Integer getQueryAdditionalFacetFieldsAsInteger() { + return getAsInteger(FessConfig.QUERY_ADDITIONAL_FACET_FIELDS); + } + + public String getQueryAdditionalSortFields() { + return get(FessConfig.QUERY_ADDITIONAL_SORT_FIELDS); + } + + public Integer getQueryAdditionalSortFieldsAsInteger() { + return getAsInteger(FessConfig.QUERY_ADDITIONAL_SORT_FIELDS); + } + + public String getQueryAdditionalNotAnalyzedFields() { + return get(FessConfig.QUERY_ADDITIONAL_NOT_ANALYZED_FIELDS); + } + + public Integer getQueryAdditionalNotAnalyzedFieldsAsInteger() { + return getAsInteger(FessConfig.QUERY_ADDITIONAL_NOT_ANALYZED_FIELDS); + } + public String getQueryDefaultLanguages() { return get(FessConfig.QUERY_DEFAULT_LANGUAGES); } diff --git a/src/main/java/org/codelibs/fess/mylasta/direction/FessProp.java b/src/main/java/org/codelibs/fess/mylasta/direction/FessProp.java index d97487d8c..ce53ac273 100644 --- a/src/main/java/org/codelibs/fess/mylasta/direction/FessProp.java +++ b/src/main/java/org/codelibs/fess/mylasta/direction/FessProp.java @@ -18,6 +18,7 @@ package org.codelibs.fess.mylasta.direction; import static org.codelibs.core.stream.StreamUtil.split; import static org.codelibs.core.stream.StreamUtil.stream; +import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.Enumeration; @@ -1322,4 +1323,84 @@ public interface FessProp { } return spaceChars; } + + String getQueryAdditionalResponseFields(); + + public default String[] getQueryAdditionalResponseFields(String... fields) { + final List list = new ArrayList<>(fields.length + 10); + stream(fields).of(stream -> stream.forEach(list::add)); + split(getQueryAdditionalResponseFields(), ",").of( + stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).forEach(list::add)); + return list.toArray(new String[list.size()]); + } + + String getQueryAdditionalCacheResponseFields(); + + public default String[] getQueryAdditionalCacheResponseFields(String... fields) { + final List list = new ArrayList<>(fields.length + 10); + stream(fields).of(stream -> stream.forEach(list::add)); + split(getQueryAdditionalCacheResponseFields(), ",").of( + stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).forEach(list::add)); + return list.toArray(new String[list.size()]); + } + + String getQueryAdditionalHighlightedFields(); + + public default String[] getQueryAdditionalHighlightedFields(String... fields) { + final List list = new ArrayList<>(fields.length + 10); + stream(fields).of(stream -> stream.forEach(list::add)); + split(getQueryAdditionalHighlightedFields(), ",").of( + stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).forEach(list::add)); + return list.toArray(new String[list.size()]); + } + + String getQueryAdditionalSearchFields(); + + public default String[] getQueryAdditionalSearchFields(String... fields) { + final List list = new ArrayList<>(fields.length + 10); + stream(fields).of(stream -> stream.forEach(list::add)); + split(getQueryAdditionalSearchFields(), ",").of( + stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).forEach(list::add)); + return list.toArray(new String[list.size()]); + } + + String getQueryAdditionalFacetFields(); + + public default String[] getQueryAdditionalFacetFields(String... fields) { + final List list = new ArrayList<>(fields.length + 10); + stream(fields).of(stream -> stream.forEach(list::add)); + split(getQueryAdditionalFacetFields(), ",").of( + stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).forEach(list::add)); + return list.toArray(new String[list.size()]); + } + + String getQueryAdditionalSortFields(); + + public default String[] getQueryAdditionalSortFields(String... fields) { + final List list = new ArrayList<>(fields.length + 10); + stream(fields).of(stream -> stream.forEach(list::add)); + split(getQueryAdditionalSortFields(), ",") + .of(stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).forEach(list::add)); + return list.toArray(new String[list.size()]); + } + + String getQueryAdditionalApiResponseFields(); + + public default String[] getQueryAdditionalApiResponseFields(String... fields) { + final List list = new ArrayList<>(fields.length + 10); + stream(fields).of(stream -> stream.forEach(list::add)); + split(getQueryAdditionalApiResponseFields(), ",").of( + stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).forEach(list::add)); + return list.toArray(new String[list.size()]); + } + + String getQueryAdditionalNotAnalyzedFields(); + + public default String[] getQueryAdditionalNotAnalyzedFields(String... fields) { + final List list = new ArrayList<>(fields.length + 10); + stream(fields).of(stream -> stream.forEach(list::add)); + split(getQueryAdditionalNotAnalyzedFields(), ",").of( + stream -> stream.filter(StringUtil::isNotBlank).map(s -> s.trim()).forEach(list::add)); + return list.toArray(new String[list.size()]); + } } diff --git a/src/main/resources/fess_config.properties b/src/main/resources/fess_config.properties index a25915f71..98086edd3 100644 --- a/src/main/resources/fess_config.properties +++ b/src/main/resources/fess_config.properties @@ -197,6 +197,14 @@ index.indices.timeout=1m query.max.length=1000 query.geo.fields=location query.replace.term.with.prefix.query=true +query.additional.response.fields= +query.additional.api.response.fields= +query.additional.cache.response.fields= +query.additional.highlighted.fields= +query.additional.search.fields= +query.additional.facet.fields= +query.additional.sort.fields= +query.additional.not.analyzed.fields= query.default.languages= query.language.mapping=\ ar=ar\n\