package org.digdata.swustoj.sort;
import org.apache.lucene.search.Sort;
import org.apache.lucene.search.SortField;
/**
* Created by wwhhff11 on 16-8-15.
*/
public class LuceneSortFactory {
/**
* 获取排序对象
* 按照某个字段进行排序
*
* @param field
* @return
*/
public static Sort getSortByField (String field, Boolean desc) {
Sort sort = new Sort();
sort.setSort(new SortField(field, SortField.Type.DOC, desc));
return sort;
}
}
package org.digdata.swustoj.sort;
import org.apache.lucene.search.Sort;
import org.apache.lucene.search.SortField;
/**
* Created by wwhhff11 on 16-8-15.
*/
public class LuceneSortFactory {
/**
* 获取排序对象
* 按照某个字段进行排序
*
* @param field
* @return
*/
public static Sort getSortByField (String field, Boolean desc) {
Sort sort = new Sort();
sort.setSort(new SortField(field, SortField.Type.DOC, desc));
return sort;
}
}
package org.digdata.swustoj.lucene;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.cn.smart.SmartChineseAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.IntField;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.TrackingIndexWriter;
import org.apache.lucene.search.*;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.SimpleFSDirectory;
import org.digdata.swustoj.sort.LuceneSortFactory;
import org.digdata.swustoj.util.PropertiesUtil;
import javax.validation.constraints.NotNull;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by hongfei.whf on 2016/8/15.
*/
public class LuceneTemplate {
public static final int DEFAULT_MAXX_ROWS = 2000 ;
public static