diff --git a/src/main/java/org/codelibs/fess/entity/SearchRequestParams.java b/src/main/java/org/codelibs/fess/entity/SearchRequestParams.java index 1bd3e0ba9..a719da3ea 100644 --- a/src/main/java/org/codelibs/fess/entity/SearchRequestParams.java +++ b/src/main/java/org/codelibs/fess/entity/SearchRequestParams.java @@ -34,6 +34,8 @@ public interface SearchRequestParams { String AS_Q = "q"; + String AS_FILETYPE = "filetype"; + String getQuery(); Map getFields(); @@ -67,7 +69,8 @@ public interface SearchRequestParams { return !isEmptyArray(conditions.get(AS_Q))// || !isEmptyArray(conditions.get(AS_EPQ))// || !isEmptyArray(conditions.get(AS_OQ))// - || !isEmptyArray(conditions.get(AS_NQ)); + || !isEmptyArray(conditions.get(AS_NQ))// + || !isEmptyArray(conditions.get(AS_FILETYPE)); } public default boolean isEmptyArray(String[] values) { diff --git a/src/main/java/org/codelibs/fess/mylasta/action/FessLabels.java b/src/main/java/org/codelibs/fess/mylasta/action/FessLabels.java index 4ab4abe64..15dbeff44 100644 --- a/src/main/java/org/codelibs/fess/mylasta/action/FessLabels.java +++ b/src/main/java/org/codelibs/fess/mylasta/action/FessLabels.java @@ -2685,18 +2685,39 @@ public class FessLabels extends UserMessages { /** The key of the message: Advanced Search */ public static final String LABELS_advance_search_title = "{labels.advance_search_title}"; - /** The key of the message: All these words: */ + /** The key of the message: All these words */ public static final String LABELS_advance_search_must_queries = "{labels.advance_search_must_queries}"; - /** The key of the message: This exact word or phrase: */ + /** The key of the message: This exact word or phrase */ public static final String LABELS_advance_search_phrase_query = "{labels.advance_search_phrase_query}"; - /** The key of the message: Any of these words: */ + /** The key of the message: Any of these words */ public static final String LABELS_advance_search_should_queries = "{labels.advance_search_should_queries}"; - /** The key of the message: None of these words: */ + /** The key of the message: None of these words */ public static final String LABELS_advance_search_not_queries = "{labels.advance_search_not_queries}"; + /** The key of the message: File Type */ + public static final String LABELS_advance_search_filetype = "{labels.advance_search_filetype}"; + + /** The key of the message: All Type */ + public static final String LABELS_advance_search_filetype_default = "{labels.advance_search_filetype_default}"; + + /** The key of the message: HTML */ + public static final String LABELS_advance_search_filetype_html = "{labels.advance_search_filetype_html}"; + + /** The key of the message: PDF */ + public static final String LABELS_advance_search_filetype_pdf = "{labels.advance_search_filetype_pdf}"; + + /** The key of the message: MS Word */ + public static final String LABELS_advance_search_filetype_word = "{labels.advance_search_filetype_word}"; + + /** The key of the message: MS Excel */ + public static final String LABELS_advance_search_filetype_excel = "{labels.advance_search_filetype_excel}"; + + /** The key of the message: MS PowerPoint */ + public static final String LABELS_advance_search_filetype_powerpoint = "{labels.advance_search_filetype_powerpoint}"; + /** * Assert the property is not null. * @param property The value of the property. (NotNull) diff --git a/src/main/java/org/codelibs/fess/util/QueryStringBuilder.java b/src/main/java/org/codelibs/fess/util/QueryStringBuilder.java index 10e2e7267..a49b8731d 100644 --- a/src/main/java/org/codelibs/fess/util/QueryStringBuilder.java +++ b/src/main/java/org/codelibs/fess/util/QueryStringBuilder.java @@ -124,6 +124,9 @@ public class QueryStringBuilder { s -> s.filter(StringUtil::isNotBlank).map(q -> "NOT " + q).collect(Collectors.joining(" "))); queryBuf.append(' ').append(nq); })); + stream(conditions.get(SearchRequestParams.AS_FILETYPE)).of( + stream -> stream.filter(q -> StringUtil.isNotBlank(q) && q.length() <= maxQueryLength).forEach( + q -> queryBuf.append(" filetype:\"").append(q.trim()).append('"'))); } diff --git a/src/main/resources/fess_label.properties b/src/main/resources/fess_label.properties index 910828521..6a091596d 100644 --- a/src/main/resources/fess_label.properties +++ b/src/main/resources/fess_label.properties @@ -889,3 +889,10 @@ labels.advance_search_must_queries=All these words labels.advance_search_phrase_query=This exact word or phrase labels.advance_search_should_queries=Any of these words labels.advance_search_not_queries=None of these words +labels.advance_search_filetype=File Type +labels.advance_search_filetype_default=All Type +labels.advance_search_filetype_html=HTML +labels.advance_search_filetype_pdf=PDF +labels.advance_search_filetype_word=MS Word +labels.advance_search_filetype_excel=MS Excel +labels.advance_search_filetype_powerpoint=MS PowerPoint diff --git a/src/main/resources/fess_label_en.properties b/src/main/resources/fess_label_en.properties index 5656fd6c6..f58f851f2 100644 --- a/src/main/resources/fess_label_en.properties +++ b/src/main/resources/fess_label_en.properties @@ -889,3 +889,10 @@ labels.advance_search_must_queries=All these words labels.advance_search_phrase_query=This exact word or phrase labels.advance_search_should_queries=Any of these words labels.advance_search_not_queries=None of these words +labels.advance_search_filetype=File Type +labels.advance_search_filetype_default=All Type +labels.advance_search_filetype_html=HTML +labels.advance_search_filetype_pdf=PDF +labels.advance_search_filetype_word=MS Word +labels.advance_search_filetype_excel=MS Excel +labels.advance_search_filetype_powerpoint=MS PowerPoint diff --git a/src/main/resources/fess_label_ja.properties b/src/main/resources/fess_label_ja.properties index f69a2abcf..af13c9511 100644 --- a/src/main/resources/fess_label_ja.properties +++ b/src/main/resources/fess_label_ja.properties @@ -891,3 +891,10 @@ labels.advance_search_must_queries=\u3059\u3079\u3066\u306e\u5358\u8a9e\u3092\u5 labels.advance_search_phrase_query=\u8a9e\u9806\u3082\u542b\u3081\u305f\u5b8c\u5168\u4e00\u81f4 labels.advance_search_should_queries=\u3044\u305a\u308c\u304b\u306e\u5358\u8a9e\u3092\u542b\u3080 labels.advance_search_not_queries=\u542b\u3081\u306a\u3044\u5358\u8a9e +labels.advance_search_filetype=\u30d5\u30a1\u30a4\u30eb\u5f62\u5f0f +labels.advance_search_filetype_default=\u3059\u3079\u3066\u306e\u5f62\u5f0f +labels.advance_search_filetype_html=HTML +labels.advance_search_filetype_pdf=PDF +labels.advance_search_filetype_word=MS Word +labels.advance_search_filetype_excel=MS Excel +labels.advance_search_filetype_powerpoint=MS PowerPoint diff --git a/src/main/webapp/WEB-INF/view/advance.jsp b/src/main/webapp/WEB-INF/view/advance.jsp index df90a336f..8da7b4fcb 100644 --- a/src/main/webapp/WEB-INF/view/advance.jsp +++ b/src/main/webapp/WEB-INF/view/advance.jsp @@ -233,6 +233,34 @@ +
+ +
+ +
+
+ +
+