fix #2280 add query.facet.queries
This commit is contained in:
parent
6a9d263f0a
commit
8ae25210ff
6 changed files with 91 additions and 99 deletions
|
@ -15,6 +15,8 @@
|
|||
*/
|
||||
package org.codelibs.fess.helper;
|
||||
|
||||
import static org.codelibs.core.stream.StreamUtil.split;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -149,7 +151,7 @@ public class ViewHelper {
|
|||
highlightTagPre = fessConfig.getQueryHighlightTagPre();
|
||||
highlightTagPost = fessConfig.getQueryHighlightTagPost();
|
||||
highlightedFields = fessConfig.getQueryHighlightContentDescriptionFieldsAsArray();
|
||||
for (int v : fessConfig.getQueryHighlightTerminalCharsAsArray()) {
|
||||
for (final int v : fessConfig.getQueryHighlightTerminalCharsAsArray()) {
|
||||
highlightTerminalCharSet.add(v);
|
||||
}
|
||||
try {
|
||||
|
@ -159,6 +161,26 @@ public class ViewHelper {
|
|||
} catch (final Throwable t) {
|
||||
logger.warn("Failed to set SessionTrackingMode.", t);
|
||||
}
|
||||
|
||||
split(fessConfig.getQueryFacetQueries(), "\n").of(stream -> stream.map(String::trim).filter(StringUtil::isNotEmpty).forEach(s -> {
|
||||
final String[] values = StringUtils.split(s, ":", 2);
|
||||
if (values.length != 2) {
|
||||
return;
|
||||
}
|
||||
final FacetQueryView facetQueryView = new FacetQueryView();
|
||||
facetQueryView.setTitle(values[0]);
|
||||
split(values[1], "\t").of(subStream -> subStream.map(String::trim).filter(StringUtil::isNotEmpty).forEach(v -> {
|
||||
final String[] facet = StringUtils.split(v, "=", 2);
|
||||
if (facet.length == 2) {
|
||||
facetQueryView.addQuery(facet[0], facet[1]);
|
||||
}
|
||||
}));
|
||||
facetQueryView.init();
|
||||
facetQueryViewList.add(facetQueryView);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("loaded {}", facetQueryView);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public String getContentTitle(final Map<String, Object> document) {
|
||||
|
|
|
@ -861,7 +861,7 @@ public class FessLabels extends UserMessages {
|
|||
public static final String LABELS_facet_filetype_aif = "{labels.facet_filetype_aif}";
|
||||
|
||||
/** The key of the message: MIDI Audio */
|
||||
public static final String LABELS_facet_filetype_mid = "{labels.facet_filetype_mid}";
|
||||
public static final String LABELS_facet_filetype_midi = "{labels.facet_filetype_midi}";
|
||||
|
||||
/** The key of the message: MPGA Audio */
|
||||
public static final String LABELS_facet_filetype_mpga = "{labels.facet_filetype_mpga}";
|
||||
|
|
|
@ -914,6 +914,12 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
|
|||
/** The key of the configuration. e.g. 0.5 */
|
||||
String QUERY_BOOST_CONTENT_LANG = "query.boost.content.lang";
|
||||
|
||||
/** The key of the configuration. e.g. labels.facet_timestamp_title:labels.facet_timestamp_1day=timestamp:[now/d-1d TO *] labels.facet_timestamp_1week=timestamp:[now/d-7d TO *] labels.facet_timestamp_1month=timestamp:[now/d-1M TO *] labels.facet_timestamp_1year=timestamp:[now/d-1y TO *]
|
||||
labels.facet_contentLength_title:labels.facet_contentLength_10k=content_length:[0 TO 9999] labels.facet_contentLength_10kto100k=content_length:[10000 TO 99999] labels.facet_contentLength_100kto500k=content_length:[100000 TO 499999] labels.facet_contentLength_500kto1m=content_length:[500000 TO 999999] labels.facet_contentLength_1m=content_length:[1000000 TO *]
|
||||
labels.facet_filetype_title:labels.facet_filetype_html=filetype:html labels.facet_filetype_word=filetype:word labels.facet_filetype_excel=filetype:excel labels.facet_filetype_powerpoint=filetype:powerpoint labels.facet_filetype_odt=filetype:odt labels.facet_filetype_ods=filetype:ods labels.facet_filetype_odp=filetype:odp labels.facet_filetype_pdf=filetype:pdf labels.facet_filetype_txt=filetype:txt labels.facet_filetype_others=filetype:others
|
||||
*/
|
||||
String QUERY_FACET_QUERIES = "query.facet.queries";
|
||||
|
||||
/** The key of the configuration. e.g. true */
|
||||
String SMB_ROLE_FROM_FILE = "smb.role.from.file";
|
||||
|
||||
|
@ -4140,6 +4146,17 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
|
|||
*/
|
||||
java.math.BigDecimal getQueryBoostContentLangAsDecimal();
|
||||
|
||||
/**
|
||||
* Get the value for the key 'query.facet.queries'. <br>
|
||||
* The value is, e.g. labels.facet_timestamp_title:labels.facet_timestamp_1day=timestamp:[now/d-1d TO *] labels.facet_timestamp_1week=timestamp:[now/d-7d TO *] labels.facet_timestamp_1month=timestamp:[now/d-1M TO *] labels.facet_timestamp_1year=timestamp:[now/d-1y TO *]
|
||||
labels.facet_contentLength_title:labels.facet_contentLength_10k=content_length:[0 TO 9999] labels.facet_contentLength_10kto100k=content_length:[10000 TO 99999] labels.facet_contentLength_100kto500k=content_length:[100000 TO 499999] labels.facet_contentLength_500kto1m=content_length:[500000 TO 999999] labels.facet_contentLength_1m=content_length:[1000000 TO *]
|
||||
labels.facet_filetype_title:labels.facet_filetype_html=filetype:html labels.facet_filetype_word=filetype:word labels.facet_filetype_excel=filetype:excel labels.facet_filetype_powerpoint=filetype:powerpoint labels.facet_filetype_odt=filetype:odt labels.facet_filetype_ods=filetype:ods labels.facet_filetype_odp=filetype:odp labels.facet_filetype_pdf=filetype:pdf labels.facet_filetype_txt=filetype:txt labels.facet_filetype_others=filetype:others
|
||||
<br>
|
||||
* comment: facet
|
||||
* @return The value of found property. (NotNull: if not found, exception but basically no way)
|
||||
*/
|
||||
String getQueryFacetQueries();
|
||||
|
||||
/**
|
||||
* Get the value for the key 'smb.role.from.file'. <br>
|
||||
* The value is, e.g. true <br>
|
||||
|
@ -7559,6 +7576,10 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
|
|||
return getAsDecimal(FessConfig.QUERY_BOOST_CONTENT_LANG);
|
||||
}
|
||||
|
||||
public String getQueryFacetQueries() {
|
||||
return get(FessConfig.QUERY_FACET_QUERIES);
|
||||
}
|
||||
|
||||
public String getSmbRoleFromFile() {
|
||||
return get(FessConfig.SMB_ROLE_FROM_FILE);
|
||||
}
|
||||
|
@ -8954,6 +8975,9 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
|
|||
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_FACET_QUERIES,
|
||||
"labels.facet_timestamp_title:labels.facet_timestamp_1day=timestamp:[now/d-1d TO *]\tlabels.facet_timestamp_1week=timestamp:[now/d-7d TO *]\tlabels.facet_timestamp_1month=timestamp:[now/d-1M TO *]\tlabels.facet_timestamp_1year=timestamp:[now/d-1y TO *]\nlabels.facet_contentLength_title:labels.facet_contentLength_10k=content_length:[0 TO 9999]\tlabels.facet_contentLength_10kto100k=content_length:[10000 TO 99999]\tlabels.facet_contentLength_100kto500k=content_length:[100000 TO 499999]\tlabels.facet_contentLength_500kto1m=content_length:[500000 TO 999999]\tlabels.facet_contentLength_1m=content_length:[1000000 TO *]\nlabels.facet_filetype_title:labels.facet_filetype_html=filetype:html\tlabels.facet_filetype_word=filetype:word\tlabels.facet_filetype_excel=filetype:excel\tlabels.facet_filetype_powerpoint=filetype:powerpoint\tlabels.facet_filetype_odt=filetype:odt\tlabels.facet_filetype_ods=filetype:ods\tlabels.facet_filetype_odp=filetype:odp\tlabels.facet_filetype_pdf=filetype:pdf\tlabels.facet_filetype_txt=filetype:txt\tlabels.facet_filetype_others=filetype:others\n");
|
||||
defaultMap.put(FessConfig.SMB_ROLE_FROM_FILE, "true");
|
||||
defaultMap.put(FessConfig.SMB_AVAILABLE_SID_TYPES, "1,2,4:2");
|
||||
defaultMap.put(FessConfig.FILE_ROLE_FROM_FILE, "true");
|
||||
|
|
|
@ -81,103 +81,6 @@
|
|||
</postConstruct>
|
||||
</component>
|
||||
<component name="viewHelper" class="org.codelibs.fess.helper.ViewHelper">
|
||||
<postConstruct name="addFacetQueryView">
|
||||
<arg>
|
||||
<component class="org.codelibs.fess.entity.FacetQueryView">
|
||||
<property name="title">"labels.facet_timestamp_title"</property>
|
||||
<postConstruct name="addQuery">
|
||||
<arg>"labels.facet_timestamp_1day"</arg>
|
||||
<arg>"timestamp:[now/d-1d TO *]"</arg>
|
||||
</postConstruct>
|
||||
<postConstruct name="addQuery">
|
||||
<arg>"labels.facet_timestamp_1week"</arg>
|
||||
<arg>"timestamp:[now/d-7d TO *]"</arg>
|
||||
</postConstruct>
|
||||
<postConstruct name="addQuery">
|
||||
<arg>"labels.facet_timestamp_1month"</arg>
|
||||
<arg>"timestamp:[now/d-1M TO *]"</arg>
|
||||
</postConstruct>
|
||||
<postConstruct name="addQuery">
|
||||
<arg>"labels.facet_timestamp_1year"</arg>
|
||||
<arg>"timestamp:[now/d-1y TO *]"</arg>
|
||||
</postConstruct>
|
||||
</component>
|
||||
</arg>
|
||||
</postConstruct>
|
||||
<postConstruct name="addFacetQueryView">
|
||||
<arg>
|
||||
<component class="org.codelibs.fess.entity.FacetQueryView">
|
||||
<property name="title">"labels.facet_contentLength_title"</property>
|
||||
<postConstruct name="addQuery">
|
||||
<arg>"labels.facet_contentLength_10k"</arg>
|
||||
<arg>"content_length:[0 TO 9999]"</arg>
|
||||
</postConstruct>
|
||||
<postConstruct name="addQuery">
|
||||
<arg>"labels.facet_contentLength_10kto100k"</arg>
|
||||
<arg>"content_length:[10000 TO 99999]"</arg>
|
||||
</postConstruct>
|
||||
<postConstruct name="addQuery">
|
||||
<arg>"labels.facet_contentLength_100kto500k"</arg>
|
||||
<arg>"content_length:[100000 TO 499999]"</arg>
|
||||
</postConstruct>
|
||||
<postConstruct name="addQuery">
|
||||
<arg>"labels.facet_contentLength_500kto1m"</arg>
|
||||
<arg>"content_length:[500000 TO 999999]"</arg>
|
||||
</postConstruct>
|
||||
<postConstruct name="addQuery">
|
||||
<arg>"labels.facet_contentLength_1m"</arg>
|
||||
<arg>"content_length:[1000000 TO *]"</arg>
|
||||
</postConstruct>
|
||||
</component>
|
||||
</arg>
|
||||
</postConstruct>
|
||||
<postConstruct name="addFacetQueryView">
|
||||
<arg>
|
||||
<component class="org.codelibs.fess.entity.FacetQueryView">
|
||||
<property name="title">"labels.facet_filetype_title"</property>
|
||||
<postConstruct name="addQuery">
|
||||
<arg>"labels.facet_filetype_html"</arg>
|
||||
<arg>"filetype:html"</arg>
|
||||
</postConstruct>
|
||||
<postConstruct name="addQuery">
|
||||
<arg>"labels.facet_filetype_word"</arg>
|
||||
<arg>"filetype:word"</arg>
|
||||
</postConstruct>
|
||||
<postConstruct name="addQuery">
|
||||
<arg>"labels.facet_filetype_excel"</arg>
|
||||
<arg>"filetype:excel"</arg>
|
||||
</postConstruct>
|
||||
<postConstruct name="addQuery">
|
||||
<arg>"labels.facet_filetype_powerpoint"</arg>
|
||||
<arg>"filetype:powerpoint"</arg>
|
||||
</postConstruct>
|
||||
<postConstruct name="addQuery">
|
||||
<arg>"labels.facet_filetype_odt"</arg>
|
||||
<arg>"filetype:odt"</arg>
|
||||
</postConstruct>
|
||||
<postConstruct name="addQuery">
|
||||
<arg>"labels.facet_filetype_ods"</arg>
|
||||
<arg>"filetype:ods"</arg>
|
||||
</postConstruct>
|
||||
<postConstruct name="addQuery">
|
||||
<arg>"labels.facet_filetype_odp"</arg>
|
||||
<arg>"filetype:odp"</arg>
|
||||
</postConstruct>
|
||||
<postConstruct name="addQuery">
|
||||
<arg>"labels.facet_filetype_pdf"</arg>
|
||||
<arg>"filetype:pdf"</arg>
|
||||
</postConstruct>
|
||||
<postConstruct name="addQuery">
|
||||
<arg>"labels.facet_filetype_txt"</arg>
|
||||
<arg>"filetype:txt"</arg>
|
||||
</postConstruct>
|
||||
<postConstruct name="addQuery">
|
||||
<arg>"labels.facet_filetype_others"</arg>
|
||||
<arg>"filetype:others"</arg>
|
||||
</postConstruct>
|
||||
</component>
|
||||
</arg>
|
||||
</postConstruct>
|
||||
<postConstruct name="addInlineMimeType">
|
||||
<arg>"application/pdf"</arg>
|
||||
</postConstruct>
|
||||
|
|
|
@ -499,6 +499,31 @@ query.boost.title.lang=1.0
|
|||
query.boost.content=0.005
|
||||
query.boost.content.lang=0.5
|
||||
|
||||
# facet
|
||||
query.facet.queries=\
|
||||
labels.facet_timestamp_title:\
|
||||
labels.facet_timestamp_1day=timestamp:[now/d-1d TO *]\t\
|
||||
labels.facet_timestamp_1week=timestamp:[now/d-7d TO *]\t\
|
||||
labels.facet_timestamp_1month=timestamp:[now/d-1M TO *]\t\
|
||||
labels.facet_timestamp_1year=timestamp:[now/d-1y TO *]\n\
|
||||
labels.facet_contentLength_title:\
|
||||
labels.facet_contentLength_10k=content_length:[0 TO 9999]\t\
|
||||
labels.facet_contentLength_10kto100k=content_length:[10000 TO 99999]\t\
|
||||
labels.facet_contentLength_100kto500k=content_length:[100000 TO 499999]\t\
|
||||
labels.facet_contentLength_500kto1m=content_length:[500000 TO 999999]\t\
|
||||
labels.facet_contentLength_1m=content_length:[1000000 TO *]\n\
|
||||
labels.facet_filetype_title:\
|
||||
labels.facet_filetype_html=filetype:html\t\
|
||||
labels.facet_filetype_word=filetype:word\t\
|
||||
labels.facet_filetype_excel=filetype:excel\t\
|
||||
labels.facet_filetype_powerpoint=filetype:powerpoint\t\
|
||||
labels.facet_filetype_odt=filetype:odt\t\
|
||||
labels.facet_filetype_ods=filetype:ods\t\
|
||||
labels.facet_filetype_odp=filetype:odp\t\
|
||||
labels.facet_filetype_pdf=filetype:pdf\t\
|
||||
labels.facet_filetype_txt=filetype:txt\t\
|
||||
labels.facet_filetype_others=filetype:others\n\
|
||||
|
||||
# acl
|
||||
smb.role.from.file=true
|
||||
smb.available.sid.types=1,2,4:2
|
||||
|
|
|
@ -19,11 +19,13 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.codelibs.core.io.FileUtil;
|
||||
import org.codelibs.core.misc.DynamicProperties;
|
||||
import org.codelibs.fess.entity.FacetQueryView;
|
||||
import org.codelibs.fess.es.config.exentity.PathMapping;
|
||||
import org.codelibs.fess.mylasta.direction.FessConfig;
|
||||
import org.codelibs.fess.unit.UnitFessTestCase;
|
||||
|
@ -52,6 +54,8 @@ public class ViewHelperTest extends UnitFessTestCase {
|
|||
pathMappingHelper = new PathMappingHelper();
|
||||
pathMappingHelper.init();
|
||||
ComponentUtil.register(pathMappingHelper, "pathMappingHelper");
|
||||
FileTypeHelper fileTypeHelper = new FileTypeHelper();
|
||||
ComponentUtil.register(fileTypeHelper, "fileTypeHelper");
|
||||
viewHelper = new ViewHelper();
|
||||
viewHelper.init();
|
||||
}
|
||||
|
@ -62,6 +66,20 @@ public class ViewHelperTest extends UnitFessTestCase {
|
|||
super.tearDown();
|
||||
}
|
||||
|
||||
public void test_facetQueries() {
|
||||
final List<FacetQueryView> list = viewHelper.getFacetQueryViewList();
|
||||
assertEquals(3, list.size());
|
||||
FacetQueryView view1 = list.get(0);
|
||||
assertEquals("labels.facet_timestamp_title", view1.getTitle());
|
||||
assertEquals(4, view1.getQueryMap().size());
|
||||
FacetQueryView view2 = list.get(1);
|
||||
assertEquals("labels.facet_contentLength_title", view2.getTitle());
|
||||
assertEquals(5, view2.getQueryMap().size());
|
||||
FacetQueryView view3 = list.get(2);
|
||||
assertEquals("labels.facet_filetype_title", view3.getTitle());
|
||||
assertEquals(10, view3.getQueryMap().size());
|
||||
}
|
||||
|
||||
public void test_getUrlLink() throws IOException {
|
||||
ComponentUtil.setFessConfig(new FessConfig.SimpleImpl() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
|
Loading…
Add table
Reference in a new issue