fix #1538 add filetype to advanced search page

This commit is contained in:
Shinsuke Sugaya 2018-03-04 22:28:00 +09:00
parent 66fa5776cf
commit 6284f2e6f7
7 changed files with 81 additions and 5 deletions

View file

@ -34,6 +34,8 @@ public interface SearchRequestParams {
String AS_Q = "q";
String AS_FILETYPE = "filetype";
String getQuery();
Map<String, String[]> 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) {

View file

@ -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)

View file

@ -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('"')));
}

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -233,6 +233,34 @@
</div>
</div>
</c:if>
<div class="form-group row">
<label for="as_filetype" class="col-lg-3 col-md-4 col-sm-5 col-xs-6 col-form-label"><la:message
key="labels.advance_search_filetype"
/></label>
<div class="col-lg-5 col-md-8 col-sm-7 col-xs-6">
<select id="as_filetype" name="as.filetype" class="form-control">
<option><la:message key="labels.advance_search_filetype_default" /></option>
<option value="html" <c:if test="${as.filetype.contains('html')}">selected</c:if>><la:message
key="labels.advance_search_filetype_html"
/></option>
<option value="pdf" <c:if test="${as.filetype.contains('pdf')}">selected</c:if>><la:message
key="labels.advance_search_filetype_pdf"
/></option>
<option value="word" <c:if test="${as.filetype.contains('word')}">selected</c:if>><la:message
key="labels.advance_search_filetype_word"
/></option>
<option value="excel" <c:if test="${as.filetype.contains('excel')}">selected</c:if>><la:message
key="labels.advance_search_filetype_excel"
/></option>
<option value="powerpoint" <c:if test="${as.filetype.contains('powerpoint')}">selected</c:if>><la:message
key="labels.advance_search_filetype_powerpoint"
/></option>
</select>
</div>
<div class="col-lg-4 hidden-md-down">
<!-- TODO -->
</div>
</div>
<div class="center">
<button type="submit" name="search" id="searchButton" class="btn btn-primary">