발단 코드, 어떻게 재구성하는지 봅시다.
7869 단어 재구성
public void warmUpContactSearcher(IndexSearcher newSearcher) throws Exception {
final Sort sortByName = new Sort(new SortField(FLD_NAME_LAST, SortField.STRING));
final Analyzer analyzer = LuceneSearcher.getAnalyzer();
final QueryParser parser = new QueryParser(FLD_COMPANY_KEYWORDS, analyzer);
final int maxContactResults = 100;
logger.debug("Contact search: company keyword jigsaw");
Query query = getKeywordQuery(LuceneSearcher.FLD_COMPANY_KEYWORDS, "jigsaw");
Sort sort = new Sort(new SortField(LuceneSearcher.FLD_COMPANY_NAME,
SortField.STRING, false));
newSearcher.search(query, null, maxContactResults, sort);
logger.debug("Contact search: company keyword intel");
query = new TermQuery(new Term(FLD_COMPANY_KEYWORDS, "intel"));
newSearcher.search(query, null, maxContactResults, sortByName);
logger.debug("Contact search: company keyword Intel Corporation");
query = LuceneSearcher.getInstance().getKeywordQuery(FLD_COMPANY_KEYWORDS,
"Intel Corporation");
newSearcher.search(query, null, maxContactResults, sortByName);
logger.debug("Contact search: company keyword :intel");
query = parser.parse(FLD_COMPANY_KEYWORDS + ":Intel");
newSearcher.search(query, null, maxContactResults, sortByName);
logger.debug("Contact search: title keyword director");
query = new TermQuery(new Term(FLD_TITLE_KEYWORDS, "director"));
newSearcher.search(query, null, maxContactResults, sortByName);
logger.debug("Contact search: title keyword :Director");
query = parser.parse(FLD_TITLE_KEYWORDS + ":Director");
newSearcher.search(query, null, maxContactResults, sortByName);
logger.debug("Contact search: company class1 1100000");
query = new TermQuery(new Term(FLD_COMPANY_CLASS1, "1100000"));
newSearcher.search(query, null, maxContactResults, sortByName);
char lastChar = 'z';
String alphabet = "abcdefghijklmnopqrstuvwxy";
for (int i = 0; i < alphabet.length(); i++) {
String lowerName = alphabet.substring(i, i + 1);
logger.debug("Contact search: last name " + lowerName + "-" + lastChar);
query = new ConstantScoreRangeQuery(FLD_NAME_FIRST, lowerName,
String.valueOf(lastChar), true, false);
newSearcher.search(query, null, maxContactResults, sortByName);
}
logger.debug("Contact search: last name smith");
query = new TermQuery(new Term(FLD_NAME_LAST, "smith"));
newSearcher.search(query, null, maxContactResults, sortByName);
logger.debug("Contact search: company keyword intel, title keyword director");
BooleanQuery booleanQuery = new BooleanQuery();
booleanQuery.add(new TermQuery(new Term(FLD_COMPANY_KEYWORDS, "intel")),
BooleanClause.Occur.MUST);
booleanQuery.add(new TermQuery(new Term(FLD_TITLE_KEYWORDS, "director")),
BooleanClause.Occur.MUST);
newSearcher.search(booleanQuery, null, maxContactResults, sortByName);
logger.debug("Contact search: company keyword intel, title keyword :Director");
query = parser.parse("+" + FLD_COMPANY_KEYWORDS + ":Intel +" + FLD_TITLE_KEYWORDS
+ ":Director");
newSearcher.search(query, null, maxContactResults, sortByName);
logger.debug("Contact search: dept1 " + Constant.DEPT_ITIS);
query = new TermQuery(new Term(FLD_DEPT1, "" + Constant.DEPT_ITIS));
newSearcher.search(query, null, maxContactResults, sortByName);
logger.debug("Contact search: dept1 " + Constant.DEPT_ITIS +
", rank directory, state CA ");
booleanQuery = new BooleanQuery();
Query dept = new TermQuery(new Term(FLD_DEPT1, "" + Constant.DEPT_ITIS));
booleanQuery.add(dept, BooleanClause.Occur.MUST);
Query rank = new TermQuery(new Term(FLD_RANK, "" + Constant.RANK_DIRECTOR));
booleanQuery.add(rank, BooleanClause.Occur.MUST);
Query state = new TermQuery(new Term(FLD_STATE, ""
+ GeoConstant.US_STATE_CALIFORNIA));
booleanQuery.add(state, BooleanClause.Occur.MUST);
newSearcher.search(booleanQuery, null, maxContactResults, sortByName);
logger.debug("Contact search: area code 415");
query = new TermQuery(new Term(FLD_AREA_CODE, "415"));
newSearcher.search(query, null, maxContactResults, sortByName);
logger.debug("Contact search: rank other");
query = new TermQuery(new Term(FLD_RANK, "500"));
newSearcher.search(query, null, maxContactResults, sortByName);
logger.debug("Contact search: state 209");
query = new TermQuery(new Term(FLD_STATE, "209"));
newSearcher.search(query, null, maxContactResults, sortByName);
logger.debug("Contact search: company id C- 0000023080");
query = new TermQuery(new Term(FLD_COMPANY_ID, "C- 0000023080"));
newSearcher.search(query, null, maxContactResults, sortByName);
logger.debug("Contact search: last name aa - al");
booleanQuery = new BooleanQuery();
booleanQuery.add(new TermQuery(new Term(FLD_IS_SEARCH_DISABLED,
Boolean.FALSE.toString())), BooleanClause.Occur.MUST);
booleanQuery.add(new ConstantScoreRangeQuery(FLD_NAME_LAST, "aa", "al", true,
false), BooleanClause.Occur.MUST);
newSearcher.search(booleanQuery, null, maxContactResults, sortByName);
logger.debug("Contact search: last name aa - al");
String queryText = "+(class1:1020000 class2:1020000 class3:1020000 class1:1030000 class2:1030000 class3:1030000 class1:1230000 class2:1230000 class3:1230000 class1:1060000 class2:1060000 class3:1060000 class1:1070000 class2:1070000 class3:1070000 class1:1100000 class2:1100000 class3:1100000 class1:1110000 class2:1110000 class3:1110000 class1:1120000 class2:1120000 class3:1120000 class1:1140000 class2:1140000 class3:1140000 class1:1160000 class2:1160000 class3:1160000 class1:1180000 class2:1180000 class3:1180000 class1:1190000 class2:1190000 class3:1190000 class1:1200000 class2:1200000 class3:1200000 class1:1210000 class2:1210000 class3:1210000 class1:1220000 class2:1220000 class3:1220000) +type:1 +(employees:40 employees:20 employees:30) +(revenue:40 revenue:20 revenue:30) +(rank:10 rank:30 rank:20) +(dept1:10 dept2:10 dept3:10 dept1:20 dept2:20 dept3:20) +country:9000 +state:9005";
logger.debug("Contact search: " + queryText);
query = parser.parse(queryText);
newSearcher.search(query, null, maxContactResults, sortByName);
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
트리 - 중간 순서와 앞 순서, 중간 순서와 뒤 순서로 두 갈래 트리 재구성제목: 두 갈래 나무의 앞 순서와 중간 순서의 결과를 입력하고 이 두 갈래 나무를 재건하십시오. 입력에 중복된 숫자가 없다고 가정하십시오. 예를 들어 앞 순서 반복 시퀀스 {1,2,4,7,3,5,6,8}와 중간 순서...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.