提交 877fe0e7 编写于 作者: Z zhourui

修复搜索分类全选时collector为空时的报错.

上级 79b8532e
...@@ -21,7 +21,7 @@ public class General extends ConfigObject { ...@@ -21,7 +21,7 @@ public class General extends ConfigObject {
private static final Boolean DEFAULT_WEBSOCKETENABLE = true; private static final Boolean DEFAULT_WEBSOCKETENABLE = true;
private static final Boolean DEFAULT_CONFIGAPIENABLE = true; private static final Boolean DEFAULT_CONFIGAPIENABLE = true;
private static final List<String> DEFAULT_SCRIPTINGBLOCKEDCLASSES = Arrays.asList(Runtime.class.getName(), private static final List<String> DEFAULT_SCRIPTINGBLOCKEDCLASSES = Arrays.asList(Runtime.class.getName(),
File.class.getName(), Path.class.getName(), ProcessBuilder.class.getName()); File.class.getName(), Path.class.getName(), java.lang.ProcessBuilder.class.getName());
private static final Boolean DEFAULT_REQUESTLOGENABLE = false; private static final Boolean DEFAULT_REQUESTLOGENABLE = false;
private static final Integer DEFAULT_REQUESTLOGRETAINDAYS = 7; private static final Integer DEFAULT_REQUESTLOGRETAINDAYS = 7;
private static final Boolean DEFAULT_REQUESTLOGBODYENABLE = false; private static final Boolean DEFAULT_REQUESTLOGBODYENABLE = false;
......
...@@ -33,7 +33,7 @@ public class StackTraceTask implements Job { ...@@ -33,7 +33,7 @@ public class StackTraceTask implements Job {
String file = Config.dir_logs().getAbsolutePath() + "/jstack_" + Config.node() + "_" String file = Config.dir_logs().getAbsolutePath() + "/jstack_" + Config.node() + "_"
+ DateTools.format(now, DateTools.formatCompact_yyyyMMddHHmmss) + ".txt"; + DateTools.format(now, DateTools.formatCompact_yyyyMMddHHmmss) + ".txt";
String command = Config.command_jstack_path().toString() + " -l -e " + pid + " > " + file; String command = Config.command_jstack_path().toString() + " -l -e " + pid + " > " + file;
ProcessBuilder processBuilder = new ProcessBuilder(); java.lang.ProcessBuilder processBuilder = new java.lang.ProcessBuilder();
if (SystemUtils.IS_OS_WINDOWS) { if (SystemUtils.IS_OS_WINDOWS) {
processBuilder.command("cmd", "/c", command); processBuilder.command("cmd", "/c", command);
} else { } else {
......
...@@ -24,7 +24,7 @@ public class HeapDump { ...@@ -24,7 +24,7 @@ public class HeapDump {
String file = Config.dir_logs().getAbsolutePath() + "/jmap_" + Config.node() + "_" String file = Config.dir_logs().getAbsolutePath() + "/jmap_" + Config.node() + "_"
+ DateTools.format(now, DateTools.formatCompact_yyyyMMddHHmmss) + ".hprof"; + DateTools.format(now, DateTools.formatCompact_yyyyMMddHHmmss) + ".hprof";
String command = Config.command_jmap_path().toString() + " -dump:format=b,file=" + file + " " + pid; String command = Config.command_jmap_path().toString() + " -dump:format=b,file=" + file + " " + pid;
ProcessBuilder processBuilder = new ProcessBuilder(); java.lang.ProcessBuilder processBuilder = new java.lang.ProcessBuilder();
if (SystemUtils.IS_OS_WINDOWS) { if (SystemUtils.IS_OS_WINDOWS) {
processBuilder.command("cmd", "/c", command); processBuilder.command("cmd", "/c", command);
} else { } else {
......
...@@ -29,7 +29,7 @@ public class ThreadDump { ...@@ -29,7 +29,7 @@ public class ThreadDump {
String file = Config.dir_logs().getAbsolutePath() + "/jstack_" + Config.node() + "_" String file = Config.dir_logs().getAbsolutePath() + "/jstack_" + Config.node() + "_"
+ DateTools.format(now, DateTools.formatCompact_yyyyMMddHHmmss) + ".txt"; + DateTools.format(now, DateTools.formatCompact_yyyyMMddHHmmss) + ".txt";
String command = Config.command_jstack_path().toString() + " -l -e " + pid + " > " + file; String command = Config.command_jstack_path().toString() + " -l -e " + pid + " > " + file;
ProcessBuilder processBuilder = new ProcessBuilder(); java.lang.ProcessBuilder processBuilder = new java.lang.ProcessBuilder();
if (SystemUtils.IS_OS_WINDOWS) { if (SystemUtils.IS_OS_WINDOWS) {
processBuilder.command("cmd", "/c", command); processBuilder.command("cmd", "/c", command);
} else { } else {
......
...@@ -334,7 +334,7 @@ public class Business { ...@@ -334,7 +334,7 @@ public class Business {
LOGGER.debug("enhance command:{}.", () -> command); LOGGER.debug("enhance command:{}.", () -> command);
ProcessBuilder processBuilder = new ProcessBuilder(); java.lang.ProcessBuilder processBuilder = new java.lang.ProcessBuilder();
if (SystemUtils.IS_OS_WINDOWS) { if (SystemUtils.IS_OS_WINDOWS) {
processBuilder.command("cmd", "/c", command); processBuilder.command("cmd", "/c", command);
......
...@@ -19,6 +19,7 @@ import org.apache.lucene.index.DirectoryReader; ...@@ -19,6 +19,7 @@ import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexableField; import org.apache.lucene.index.IndexableField;
import org.apache.lucene.search.BooleanClause; import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.Collector;
import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.MultiCollector; import org.apache.lucene.search.MultiCollector;
import org.apache.lucene.search.Query; import org.apache.lucene.search.Query;
...@@ -80,6 +81,9 @@ class ActionPost extends BaseAction { ...@@ -80,6 +81,9 @@ class ActionPost extends BaseAction {
} }
Analyzer analyzer = new HanLPAnalyzer(); Analyzer analyzer = new HanLPAnalyzer();
Optional<Query> searchQuery = this.searchQuery(wi.getQuery(), analyzer); Optional<Query> searchQuery = this.searchQuery(wi.getQuery(), analyzer);
if (searchQuery.isEmpty()) {
return result;
}
Optional<Query> readersQuery = Indexs.readersQuery(readers); Optional<Query> readersQuery = Indexs.readersQuery(readers);
List<Query> filterQueries = Indexs.filterQueries(wi.getFilterList()); List<Query> filterQueries = Indexs.filterQueries(wi.getFilterList());
...@@ -110,8 +114,13 @@ class ActionPost extends BaseAction { ...@@ -110,8 +114,13 @@ class ActionPost extends BaseAction {
org.apache.lucene.search.Sort.INDEXORDER, org.apache.lucene.search.Sort.INDEXORDER,
facetMaxGroups))) facetMaxGroups)))
.collect(Collectors.toList()); .collect(Collectors.toList());
searcher.search(query, MultiCollector.wrap(topScoreDocCollector, MultiCollector
.wrap(firstPassGroupingCollectorPairs.stream().map(Pair::second).collect(Collectors.toList())))); List<Collector> collectors = firstPassGroupingCollectorPairs.stream().map(Pair::second)
.collect(Collectors.toList());
collectors.add(topScoreDocCollector);
searcher.search(query, MultiCollector.wrap(collectors));
writeDocument(searcher, analyzer, highlighter, topScoreDocCollector, start, rows, wo); writeDocument(searcher, analyzer, highlighter, topScoreDocCollector, start, rows, wo);
List<Pair<String, TopGroupsCollector<BytesRef>>> topGroupsCollectorPairs = firstPassGroupingCollectorPairs List<Pair<String, TopGroupsCollector<BytesRef>>> topGroupsCollectorPairs = firstPassGroupingCollectorPairs
.stream().<Pair<String, Optional<Collection<SearchGroup<BytesRef>>>>>map(param -> { .stream().<Pair<String, Optional<Collection<SearchGroup<BytesRef>>>>>map(param -> {
......
...@@ -42,8 +42,7 @@ abstract class BaseAction extends StandardJaxrsAction { ...@@ -42,8 +42,7 @@ abstract class BaseAction extends StandardJaxrsAction {
protected Optional<Query> searchQuery(String query, Analyzer analyzer) throws Exception { protected Optional<Query> searchQuery(String query, Analyzer analyzer) throws Exception {
query = Indexs.alignQuery(query); query = Indexs.alignQuery(query);
if (StringUtils.isBlank(query)) { if (StringUtils.isBlank(query)) {
// return Optional.of(new MatchAllDocsQuery()); return Optional.empty();
throw new ExceptionQueryEmpty();
} }
Query titleQuery = new QueryParser(Indexs.FIELD_TITLE, analyzer).parse(query); Query titleQuery = new QueryParser(Indexs.FIELD_TITLE, analyzer).parse(query);
Query summaryQuery = new QueryParser(Indexs.FIELD_SUMMARY, analyzer).parse(query); Query summaryQuery = new QueryParser(Indexs.FIELD_SUMMARY, analyzer).parse(query);
......
package com.x.query.assemble.surface.jaxrs.search;
import com.x.base.core.project.exception.LanguagePromptException;
class ExceptionQueryEmpty extends LanguagePromptException {
ExceptionQueryEmpty() {
super("搜索条件不能为空.");
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册