Lucene全文搜索 分组,精确查找,模糊查找
http://zm603380946.iteye.com/blog/1827318
完全个人理解,如有更好的方法,欢迎一起讨论
LuceneUtils.java
package com.zbiti.lucene;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.CorruptIndexException;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.IndexWriter.MaxFieldLength;
import org.apache.lucene.queryParser.MultiFieldQueryParser;
import org.apache.lucene.queryParser.ParseException;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.search.CachingWrapperFilter;
import org.apache.lucene.search.Filter;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.QueryWrapperFilter;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.store.LockObtainFailedException;
import org.apache.lucene.util.Version;
import org.wltea.analyzer.lucene.IKAnalyzer;
import com.zbiti.util.sys.JsonUtils;
/**
* Lucene 辅助类
* @author 张明
*
*/
public class LuceneUtils {
//读取数据放入的地址
private static String IndexPath = "C:\\update\\index";
static Directory dir = null;
//初始化静态代码块
static{
try {
dir = FSDirectory.open(new File(IndexPath));
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 创建本地文件
* @param list 传递过来的数据是一个list
* @throws Exception
*/
public static boolean createData(List<Information> list){
try {
Directory dir =FSDirectory.open(new File(IndexPath));
IndexWriterConfig writerConfig=new IndexWriterConfig(Version.LUCENE_36, new IKAnalyzer());
//设置每次创建都重新创建
writerConfig.setOpenMode(IndexWriterConfig.OpenMode.CREATE);
IndexWriter writer = new IndexWriter(dir, writerConfig) ;
//循环处理将数据放入Lucene中
for(int i=0; i< list.size(); i++){
Information information = list.get(i);
Document doc = new Document();
//设置字段
setField(information, doc);
writer.addDocument(doc);
}
//提交
writer.optimize();
writer.commit();
writer.close();
return true;
} catch (CorruptIndexException e) {
e.printStackTrace();
return false;
} catch (LockObtainFailedException e) {
e.printStackTrace();
return false;
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
/**
* 创建一条数据
* @param information 一条数据,传送过来的数据必须是完整的数据
* @return
*/
public static boolean createData(Information information){
try {
Directory dir =FSDirectory.open(new File(IndexPath));
IndexWriterConfig writerConfig=new IndexWriterConfig(Version.LUCENE_36, new IKAnalyzer());
IndexWriter writer = new IndexWriter(dir, writerConfig);
Document doc = new Document();
//设置字段
setField(information, doc);
writer.addDocument(doc);
writer.optimize();
writer.commit();
writer.close();
return true;
} catch (CorruptIndexException e) {
e.printStackTrace();
return false;
} catch (LockObtainFailedException e) {
e.printStackTrace();
return false;
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
/**
* 更新一条信息
* @param information 根据bjStorageId的唯一性来更新数据
* 传送过来的数据必须是完整的数据,Lucene的更新不同于sql更新,更新是一天信息的完整更新
* @return
*/
public static boolean updateData(Information information){
try {
Directory dir =FSDirectory.open(new File(IndexPath));
//第三个参数代表更新的时候不重新创建原本的数据
IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(Version.LUCENE_CURRENT), false, MaxFieldLength.UNLIMITED);
Document doc = new Document();
//设置字段
setField(information, doc);
Term term = new Term("bjStorageId",information.getBjStorageId().toString());
writer.updateDocument(term,doc);
writer.optimize();
writer.commit();
writer.close();
return true;
} catch (CorruptIndexException e) {
e.printStackTrace();
return false;
} catch (LockObtainFailedException e) {
e.printStackTrace();
return false;
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
/**
* 删除一条数据
* @return 根据bjStorageId的唯一性来删除数据
*/
public static boolean deleteData(String bjStorageId){
try {
Directory dir =FSDirectory.open(new File(IndexPath));
//第三个参数代表更新的时候不重新创建原本的数据
IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(Version.LUCENE_CURRENT), false, MaxFieldLength.UNLIMITED);
Term term = new Term("bjStorageId", bjStorageId);
writer.deleteDocuments(term);
writer.optimize();
writer.commit();
writer.close();
return true;
} catch (CorruptIndexException e) {
e.printStackTrace();
return false;
} catch (LockObtainFailedException e) {
e.printStackTrace();
return false;
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
/**
* 查询数据
* @param searchStr 即将要查询的字符串
* @param fieldStr 需要查询的字段数组
* @param flag 是否统计标志
* @param groupStr 分组字段数组
* @param flagAcc 是否根据条件精确查询
* @param mapFilter查询条件
* @return
*/
public static Map<String,Object> getDataList(String
searchStr, String[] fieldArray, boolean flag, String[] groupArray,
boolean flagAcc, Map<String,Object> mapFilter){
try {
IndexSearcher search = new IndexSearcher(dir);
System.out.println("lucene中的数据总数为:------->>>" + search.maxDoc());
QueryParser qp=new MultiFieldQueryParser(Version.LUCENE_36, fieldArray, new IKAnalyzer());
Query query=qp.parse(searchStr);
//一次查询多少个结果
//TopDocs tDocs=search.search(query,1000000);
TopDocs tDocs = null;
//是否二次查询,根据多条件精确查找
if(flagAcc){
LuceneFilter luceneFilter = new LuceneFilter();
Set<String> keySet = mapFilter.keySet();
for (String key : keySet)
luceneFilter.addFilter(key, mapFilter.get(key).toString());
query=luceneFilter.getFilterQuery(query);//结果过滤
tDocs = search.search(query,1000000);
}else{
tDocs=search.search(query,1000000);
}
int numTotalHits = tDocs.totalHits;
System.out.println("lucene中的搜索出来的数据总数为:------->>>" + numTotalHits);
Map<String,Object> map = new HashMap<String,Object>();
map.put("information", tDocs);
map.put("search", search);
//是否同时查询分组统计数据
if(flag){
for(int j=0; j < groupArray.length; j++){
JSONArray jsonArr = new JSONArray();
JSONObject jsonObj = new JSONObject();
Map<String,Object> groupMap = getDataByGroupBy(search, query, groupArray[j]);
Set<String> keySet = groupMap.keySet();
for (String key : keySet) {
jsonObj.put("id",key);
jsonObj.put("count", groupMap.get(key));
jsonArr.add(jsonObj);
}
map.put(groupArray[j],jsonArr);
}
}
//解析数据
// Document doc = null;
// for(int i=0; i<numTotalHits; i++){
// int k = tDocs.scoreDocs[i].doc ; //文档内部编号
// doc = search.doc(k);
// System.out.println(doc.get("name") +"--" + doc.get("id") + "-----" + doc.get("type") + "---" + doc.get("testField"));
// }
// search.close();
return map;
} catch (CorruptIndexException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}
/**
* 根据field指定的字段来进行分组统计总数
* @param search
* @param query
* @param field
*/
public static Map<String,Object> getDataByGroupBy(IndexSearcher search, Query query, String field){
try {
GroupCollector myCollector = new GroupCollector();
myCollector.setF(field);
search.search(query, myCollector);
GroupField gf = myCollector.getGroupField();
List<String> values = gf.getValues();
//读取数据
Map<String,Object> map = new HashMap<String,Object>();
for (String value : values) {
map.put(value, gf.getCountMap().get(value));
}
return map;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
/**
* 设置字段信息
* @param information
* NOT_ANALYZED不支持模糊查找, ANALYZED支持模糊查找
*/
public static void setField(Information information, Document doc){
doc.add(new Field("actualStorageId",
information.getActualStorageId()!=null?information.getActualStorageId().toString():"",
Field.Store.YES, Field.Index.NOT_ANALYZED));
doc.add(new Field("deviceId",
information.getDeviceId()!=null?information.getDeviceId().toString():"",
Field.Store.YES, Field.Index.NOT_ANALYZED));
doc.add(new Field("brandId",
information.getBrandId()!=null?information.getBrandId().toString():"",
Field.Store.YES, Field.Index.NOT_ANALYZED));
doc.add(new Field("netId",
information.getNetId()!=null?information.getNetId().toString():"",
Field.Store.YES, Field.Index.NOT_ANALYZED));
doc.add(new Field("bjSpecialtyId",
information.getBjSpecialtyId()!=null?information.getBjSpecialtyId().toString():"",
Field.Store.YES, Field.Index.NOT_ANALYZED));
doc.add(new Field("deviceType",
information.getDeviceType()!=null?information.getDeviceType().toString():"",
Field.Store.YES, Field.Index.NOT_ANALYZED));
doc.add(new Field("bjStorageId",
information.getBjStorageId()!=null?information.getBjStorageId().toString():"",
Field.Store.YES, Field.Index.NOT_ANALYZED));
doc.add(new Field("bjType",
information.getBjType()!=null?information.getBjType().toString():"",
Field.Store.YES, Field.Index.NOT_ANALYZED));
doc.add(new Field("state1Cd",
information.getState1Cd()!=null?information.getState1Cd().toString():"",
Field.Store.YES, Field.Index.NOT_ANALYZED));
doc.add(new Field("state2Cd",
information.getState2Cd()!=null?information.getState2Cd().toString():"",
Field.Store.YES, Field.Index.NOT_ANALYZED));
doc.add(new Field("isStocktake",
information.getIsStocktake()!=null?information.getIsStocktake().toString():"",
Field.Store.YES, Field.Index.NOT_ANALYZED));
doc.add(new Field("shelfId",
information.getShelfId()!=null?information.getShelfId().toString():"",
Field.Store.YES, Field.Index.NOT_ANALYZED));
/*==================================================================================================================*/
doc.add(new Field("actualStorageRoom",
information.getActualStorageRoom()!=null?information.getActualStorageRoom().toString():"",
Field.Store.YES, Field.Index.ANALYZED));
doc.add(new Field("originalSerialNum",
information.getOriginalSerialNum()!=null?information.getOriginalSerialNum().toString():"",
Field.Store.YES, Field.Index.ANALYZED));
doc.add(new Field("deviceModel",
information.getDeviceModel()!=null?information.getDeviceModel().toString():"",
Field.Store.YES, Field.Index.ANALYZED));
doc.add(new Field("frontPic",
information.getFrontPic()!=null?information.getFrontPic().toString():"",
Field.Store.YES, Field.Index.ANALYZED));
doc.add(new Field("brandName",
information.getBrandName()!=null?information.getBrandName().toString():"",
Field.Store.YES, Field.Index.ANALYZED));
doc.add(new Field("netType",
information.getNetType()!=null?information.getNetType().toString():"",
Field.Store.YES, Field.Index.ANALYZED));
doc.add(new Field("netName",
information.getNetName()!=null?information.getNetName().toString():"",
Field.Store.YES, Field.Index.ANALYZED));
doc.add(new Field("specialtyName",
information.getSpecialtyName()!=null?information.getSpecialtyName().toString():"",
Field.Store.YES, Field.Index.ANALYZED));
doc.add(new Field("shelfCode",
information.getShelfName()!=null?information.getShelfName().toString():"",
Field.Store.YES, Field.Index.ANALYZED));
}
public static void main(String[] args) {
}
}
//辅助类
LuceneFilter.java
package com.zbiti.lucene;
import java.util.ArrayList;
import java.util.List;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.Filter;
import org.apache.lucene.search.FilteredQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.QueryWrapperFilter;
import org.apache.lucene.search.TermQuery;
/**
* 条件辅助类
* @author 张明
*
*/
public class LuceneFilter {
private List<Filter> filterList;
public LuceneFilter(){
filterList = new ArrayList<Filter>();
}
public void addFilter(String Field,String Value){
Term term=new Term(Field,Value);//添加term
QueryWrapperFilter filter=new QueryWrapperFilter(new TermQuery(term));//添加过滤器
filterList.add(filter);//加入List,可以增加多個过滤
}
public Query getFilterQuery(Query query){
for(int i=0;i<filterList.size();i++){
//取出多個过滤器,在结果中再次定位结果
query = new FilteredQuery(query, filterList.get(i));
}
return query;
}
}
Information.java
package com.zbiti.lucene;
/**
* Bean
*
* @author 张明
*
*/
public class Information {
/**
* 实物库房ID(分组字段)
*/
private Integer actualStorageId;
/**
* 设备型号ID(分组字段)
*/
private Integer deviceId;
/**
* 品牌ID(分组字段)
*/
private Integer brandId;
/**
* 网元ID(分组字段)
*/
private Integer netId;
/**
* 专业ID(分组字段)
*/
private Integer bjSpecialtyId;
/**
* 设备类型(分组字段)
*/
private String deviceType;
/**
* 备件编号(分组字段)
*/
private Integer bjStorageId;
/** *******************区分字段******************* */
/**
* 备件类型(区分备件-BJ,送修件SXJ)(分组字段)
*/
private String bjType;
/**
* 资产库房备件状态(分组字段)
*/
private String state1Cd;
/**
* 实物库房备件状态(分组字段)
*/
private String state2Cd;
/**
* 是否已盘点(分组字段)
*/
private String isStocktake;
/**
* 网元类型(分组字段)
*/
private String netType;
/**
* 货架ID(分组字段)
*/
private Integer shelfId;
/*=======================================================*/
/**
* 实物库房
*/
private String actualStorageRoom;
/**
* 序列号(送修件原序列号)
*/
private String originalSerialNum;
/**
* 设备型号
*/
private String deviceModel;
/**
* 设备前图片
*/
private String frontPic;
/**
* 品牌名称
*/
private String brandName;
/**
* 网元名称
*/
private String netName;
/**
* 专业类别
*/
private String specialtyName;
/**
* 货架名称
*/
private String shelfName;
public Integer getBjStorageId() {
return bjStorageId;
}
public void setBjStorageId(Integer bjStorageId) {
this.bjStorageId = bjStorageId;
}
public Integer getActualStorageId() {
return actualStorageId;
}
public void setActualStorageId(Integer actualStorageId) {
this.actualStorageId = actualStorageId;
}
public String getActualStorageRoom() {
return actualStorageRoom;
}
public void setActualStorageRoom(String actualStorageRoom) {
this.actualStorageRoom = actualStorageRoom;
}
public String getOriginalSerialNum() {
return originalSerialNum;
}
public void setOriginalSerialNum(String originalSerialNum) {
this.originalSerialNum = originalSerialNum;
}
public String getState1Cd() {
return state1Cd;
}
public void setState1Cd(String state1Cd) {
this.state1Cd = state1Cd;
}
public String getState2Cd() {
return state2Cd;
}
public void setState2Cd(String state2Cd) {
this.state2Cd = state2Cd;
}
public String getIsStocktake() {
return isStocktake;
}
public void setIsStocktake(String isStocktake) {
this.isStocktake = isStocktake;
}
public Integer getDeviceId() {
return deviceId;
}
public void setDeviceId(Integer deviceId) {
this.deviceId = deviceId;
}
public String getDeviceModel() {
return deviceModel;
}
public void setDeviceModel(String deviceModel) {
this.deviceModel = deviceModel;
}
public String getDeviceType() {
return deviceType;
}
public void setDeviceType(String deviceType) {
this.deviceType = deviceType;
}
public String getFrontPic() {
return frontPic;
}
public void setFrontPic(String frontPic) {
this.frontPic = frontPic;
}
public Integer getBrandId() {
return brandId;
}
public void setBrandId(Integer brandId) {
this.brandId = brandId;
}
public String getBrandName() {
return brandName;
}
public void setBrandName(String brandName) {
this.brandName = brandName;
}
public Integer getNetId() {
return netId;
}
public void setNetId(Integer netId) {
this.netId = netId;
}
public String getNetType() {
return netType;
}
public void setNetType(String netType) {
this.netType = netType;
}
public String getNetName() {
return netName;
}
public void setNetName(String netName) {
this.netName = netName;
}
public Integer getBjSpecialtyId() {
return bjSpecialtyId;
}
public void setBjSpecialtyId(Integer bjSpecialtyId) {
this.bjSpecialtyId = bjSpecialtyId;
}
public String getSpecialtyName() {
return specialtyName;
}
public void setSpecialtyName(String specialtyName) {
this.specialtyName = specialtyName;
}
public Integer getShelfId() {
return shelfId;
}
public void setShelfId(Integer shelfId) {
this.shelfId = shelfId;
}
public String getShelfName() {
return shelfName;
}
public void setShelfName(String shelfName) {
this.shelfName = shelfName;
}
public String getBjType() {
return bjType;
}
public void setBjType(String bjType) {
this.bjType = bjType;
}
}
GroupField.java
package com.zbiti.lucene;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
* @author 张明
*
*/
public class GroupField {
// 所有可能的分组字段值,排序按每个字段值的文档个数大小排序
private List<String> values = new ArrayList<String>();
// 保存字段值和文档个数的对应关系
private Map<String, Integer> countMap = new HashMap<String, Integer>();
public Map<String, Integer> getCountMap() {
return countMap;
}
public void setCountMap(Map<String, Integer> countMap) {
this.countMap = countMap;
}
public List<String> getValues() {
Collections.sort(values, new ValueComparator());
return values;
}
public void setValues(List<String> values) {
this.values = values;
}
public void addValue(String value) {
if (value == null || "".equals(value))
return;
if (countMap.get(value) == null) {
countMap.put(value, 1);
values.add(value);
}else{
countMap.put(value, countMap.get(value) + 1);
}
}
class ValueComparator implements Comparator<String> {
public int compare(String value0, String value1) {
if (countMap.get(value0) > countMap.get(value1)) {
return -1;
} else if (countMap.get(value0) < countMap.get(value1)) {
return 1;
}
return 0;
}
}
}
GroupCollector.java
package com.zbiti.lucene;
import java.io.IOException;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.Collector;
import org.apache.lucene.search.FieldCache;
import org.apache.lucene.search.Scorer;
/**
*
* @author 张明
*
*/
public class GroupCollector extends Collector{
// 保存分组统计结果
private GroupField groupField = new GroupField();
//fieldCache
private String[] fieldCache;
//统计字段
private String field;
String spliter;
int length;
public void setFc(String[] fieldCache) {
this.fieldCache = fieldCache;
}
@Override
public void setScorer(Scorer scorer) throws IOException {
}
@Override
public void setNextReader(IndexReader reader, int docBase)
throws IOException {
fieldCache = FieldCache.DEFAULT.getStrings(reader, field);
}
@Override
public void collect(int doc) throws IOException {
// 添加的GroupField中,由GroupField负责统计每个不同值的数目
groupField.addValue(fieldCache[doc]);
}
@Override
public boolean acceptsDocsOutOfOrder() {
return true;
}
public GroupField getGroupField() {
return groupField;
}
public void setSpliter(String spliter) {
this.spliter = spliter;
}
public void setLength(int length) {
this.length = length;
}
public void setF(String field) {
this.field = field;
}
}
//测试类
package com.zbiti.lucene;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.CorruptIndexException;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.TopDocs;
public class TestLucene {
public static void main(String[] args) throws CorruptIndexException, IOException {
//创建
List<Information> list = new ArrayList<Information>();
for(int i=0; i< 10000; i++){
Information information = new Information();
information.setActualStorageId(i);
information.setDeviceId(i);
if(i<300)
information.setBrandId(8888);
else
information.setBrandId(7777);
if(i < 500)
information.setNetId(100);
else
information.setNetId(200);
information.setBjSpecialtyId(i);
if(i <= 100)
information.setDeviceType("AMD");
else
information.setDeviceType("INTEL");
information.setBjStorageId(i);
if(i <= 20)
information.setActualStorageRoom("实际库房名称");
else
information.setActualStorageRoom("库房名称");
information.setOriginalSerialNum("序列号");
information.setState1Cd("001");
information.setState2Cd("002");
information.setIsStocktake("true");
information.setDeviceModel("设备型号");
information.setFrontPic("/pm/tp.png");
if(i <= 600 && i > 500)
information.setBrandName("实际银行名称");
else
information.setBrandName("银行名称");
information.setNetType("网元类型");
information.setNetName("网元名称");
information.setSpecialtyName("专业类别");
information.setShelfId(i);
information.setShelfName("货架编码名称");
information.setBjType("BJ");
list.add(information);
}
LuceneUtils.createData(list);
//====================================================================================================
//查询
// String[] fields = {"netId"};
// String str = "100";
String[] fields = {"actualStorageRoom","brandName"};
// //不分组统计
Map<String,Object> mapFilter = new HashMap<String,Object>();
Map<String,Object> map = LuceneUtils.getDataList("实际", fields, false, null, false, mapFilter);
TopDocs topDocs = (TopDocs)map.get("information");
IndexSearcher search = (IndexSearcher)map.get("search");
// Document doc = null;
// //取数据字段内容
// for(int i=0; i<topDocs.totalHits; i++){
// int k = topDocs.scoreDocs[i].doc ; //文档内部编号
// doc = search.doc(k);
// System.out.println(doc.get("actualStorageRoom") +"--" + doc.get("brandName") + "----" + doc.get("netId")) ;
// }
// search.close();
//======================================================================================================
// //分组统计
String str5 = "100";
String[] fields5 = {"netId"};
String[] groupFields = {"deviceType"};
Map<String,Object> mapGroup = LuceneUtils.getDataList(str5, fields5, true, groupFields, false, null);
System.out.println("统计信息 ------->>> " + mapGroup.get("deviceType"));
search.close();
//=======================================================================================================
//新增
Information information = new Information();
information.setActualStorageId(80001);
information.setDeviceId(80001);
information.setBrandId(80001);
information.setNetId(80001);
information.setBjSpecialtyId(80001);
information.setDeviceType("INTEL");
information.setBjStorageId(80001);
information.setActualStorageRoom("实际库房名称");
information.setOriginalSerialNum("序列号");
information.setState1Cd("001");
information.setState2Cd("002");
information.setIsStocktake("true");
information.setDeviceModel("设备型号");
information.setFrontPic("/pm/tp.png");
information.setBrandName("银行名称");
information.setNetType("网元类型");
information.setNetName("网元名称");
information.setSpecialtyName("专业类别");
information.setShelfId(80001);
information.setShelfName("货架编码名称");
information.setBjType("BJ");
LuceneUtils.createData(information);
String str6 = "实际";
String[] fields1 = {"actualStorageRoom","brandName"};
LuceneUtils.getDataList(str6, fields1, false, null, false, null);
//更新
Information information2 = new Information();
information2.setActualStorageId(400);
information2.setDeviceId(80001);
information2.setBrandId(80001);
information2.setNetId(80001);
information2.setBjSpecialtyId(400);
information2.setDeviceType("INTEL");
information2.setBjStorageId(2);
information2.setActualStorageRoom("更新库房名称");
information2.setOriginalSerialNum("序列号");
information2.setState1Cd("001");
information2.setState2Cd("002");
information2.setIsStocktake("true");
information2.setDeviceModel("设备型号");
information2.setFrontPic("/pm/tp.png");
information2.setBrandName("银行名称");
information2.setNetType("网元类型");
information2.setNetName("网元名称");
information2.setSpecialtyName("专业类别");
information2.setShelfId(80001);
information2.setShelfName("货架编码名称");
information2.setBjType("BJ");
LuceneUtils.updateData(information2);
String str2 = "实际";
String[] fields2 = {"actualStorageRoom","brandName"};
LuceneUtils.getDataList(str2, fields2, false, null, false, null);
//删除
LuceneUtils.deleteData("600");
String str3 = "实际";
String[] fields3 = {"actualStorageRoom","brandName"};
LuceneUtils.getDataList(str3, fields3, false, null, false, null);
}
}
posted on 2015-12-10 12:05 1130136248 阅读(1165) 评论(0) 编辑 收藏 举报