|
|
@@ -5,10 +5,8 @@ import java.io.File;
|
|
|
import java.io.FileNotFoundException;
|
|
|
import java.io.FileReader;
|
|
|
import java.io.IOException;
|
|
|
-import java.io.PrintWriter;
|
|
|
import java.nio.file.Paths;
|
|
|
import java.util.Date;
|
|
|
-import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
import java.util.Set;
|
|
|
|
|
|
@@ -35,9 +33,10 @@ import com.uas.search.console.dao.KindSimpleInfoDao;
|
|
|
import com.uas.search.console.model.BrandSimpleInfo;
|
|
|
import com.uas.search.console.model.ComponentSimpleInfo;
|
|
|
import com.uas.search.console.model.KindSimpleInfo;
|
|
|
-import com.uas.search.console.model.PropertyValueSimpleInfo;
|
|
|
+import com.uas.search.console.model.PropertyValue;
|
|
|
import com.uas.search.console.service.IndexService;
|
|
|
import com.uas.search.console.support.IndexWriterManager;
|
|
|
+import com.uas.search.console.util.MergeComponentData;
|
|
|
import com.uas.search.console.util.SearchConstants;
|
|
|
|
|
|
/**
|
|
|
@@ -64,13 +63,9 @@ public class IndexServiceImpl implements IndexService {
|
|
|
|
|
|
private FSDirectory directory;
|
|
|
|
|
|
- private Logger logger = Logger.getLogger(IndexServiceImpl.class);
|
|
|
-
|
|
|
- // 分页获取component数据时的页的大小
|
|
|
private static final int PAGE_SIZE = 1000;
|
|
|
|
|
|
- // 单个文件存储的最大数据数目
|
|
|
- public static final int SINGLE_FILE_MAX_SIZE = 100000;
|
|
|
+ private Logger logger = Logger.getLogger(IndexServiceImpl.class);
|
|
|
|
|
|
public IndexServiceImpl() {
|
|
|
try {
|
|
|
@@ -82,7 +77,7 @@ public class IndexServiceImpl implements IndexService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Long createIndexes(Integer fromDB) {
|
|
|
+ public Long createIndexs() {
|
|
|
try {
|
|
|
if (IndexWriter.isLocked(directory)) {
|
|
|
logger.warn("已有线程正在创建索引!");
|
|
|
@@ -95,27 +90,22 @@ public class IndexServiceImpl implements IndexService {
|
|
|
// 清除旧索引
|
|
|
File file = new File(SearchConstants.INDEX_DIR);
|
|
|
if (file.isDirectory()) {
|
|
|
- clearDir(file);
|
|
|
+ deleteOldIndex(file);
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
indexWriter = indexWriterManager.get();
|
|
|
Long startTime = new Date().getTime();
|
|
|
|
|
|
- Long kindSize = createKindIndexes();
|
|
|
+ Long kindSize = createKindIndexs();
|
|
|
Long kindTime = new Date().getTime();
|
|
|
logger.info("创建类目索引: " + kindSize + "条,耗时 " + (kindTime - startTime) + " ms\n");
|
|
|
|
|
|
- Long brandSize = createBrandIndexes();
|
|
|
+ Long brandSize = createBrandIndexs();
|
|
|
Long brandTime = new Date().getTime();
|
|
|
logger.info("创建品牌索引: " + brandSize + "条,耗时 " + (brandTime - kindTime) + " ms\n");
|
|
|
|
|
|
- Long componentSize = 0L;
|
|
|
- if (fromDB != null && fromDB == 1) {
|
|
|
- componentSize = createComponentIndexesFromDatabase();
|
|
|
- } else {
|
|
|
- componentSize = createComponentIndexesFromFiles();
|
|
|
- }
|
|
|
+ Long componentSize = createComponentIndexesWithFiles();
|
|
|
Long componentTime = new Date().getTime();
|
|
|
logger.info("创建器件索引: " + componentSize + "条,耗时 " + (componentTime - brandTime) + " ms\n");
|
|
|
|
|
|
@@ -139,7 +129,7 @@ public class IndexServiceImpl implements IndexService {
|
|
|
* @return 写入的类目索引数
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
- private Long createKindIndexes() throws IOException {
|
|
|
+ private Long createKindIndexs() throws IOException {
|
|
|
logger.info("正在创建类目索引...");
|
|
|
List<KindSimpleInfo> kinds = kindDao.findAll();
|
|
|
|
|
|
@@ -161,7 +151,7 @@ public class IndexServiceImpl implements IndexService {
|
|
|
* @return 写入的品牌索引数
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
- private Long createBrandIndexes() throws IOException {
|
|
|
+ private Long createBrandIndexs() throws IOException {
|
|
|
logger.info("正在创建品牌索引...");
|
|
|
List<BrandSimpleInfo> brands = brandDao.findAll();
|
|
|
if (CollectionUtils.isEmpty(brands))
|
|
|
@@ -177,23 +167,18 @@ public class IndexServiceImpl implements IndexService {
|
|
|
return (long) brands.size();
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 从本地文件获取器件数据
|
|
|
- *
|
|
|
- * @return
|
|
|
- */
|
|
|
- private Long createComponentIndexesFromFiles() {
|
|
|
+ private Long createComponentIndexesWithFiles() {
|
|
|
logger.info("正在创建器件索引...");
|
|
|
Long size = 0L;
|
|
|
try {
|
|
|
// 从本地路径读取器件数据
|
|
|
- File[] files = new File(SearchConstants.COMPONENT_DATA_DIR).listFiles();
|
|
|
+ File[] files = new File(SearchConstants.COMPONENT_WITH_PROPERTY_DIR).listFiles();
|
|
|
if (files == null || files.length == 0) {
|
|
|
logger.info("创建器件索引失败,原因:器件数据文件不存在!");
|
|
|
return 0L;
|
|
|
}
|
|
|
// 将要创建的索引总数目约为:文件数目*单个文件的行数
|
|
|
- long totalSize = files.length * SINGLE_FILE_MAX_SIZE;
|
|
|
+ long totalSize = files.length * MergeComponentData.SINGLE_FILE_MAX_SIZE;
|
|
|
for (File file : files) {
|
|
|
logger.info("读取文件: " + file.getName());
|
|
|
BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
|
|
|
@@ -205,8 +190,7 @@ public class IndexServiceImpl implements IndexService {
|
|
|
size++;
|
|
|
// 每创建10000条,打印一次进度
|
|
|
if (size % 10000 == 0) {
|
|
|
- logger.info(
|
|
|
- String.format("Component indexed...............%.2f%%", size * 100.0 / totalSize));
|
|
|
+ System.out.printf("Component indexed...................%.2f%%\n", size * 100.0 / totalSize);
|
|
|
}
|
|
|
indexWriter.addDocument(document);
|
|
|
}
|
|
|
@@ -223,108 +207,13 @@ public class IndexServiceImpl implements IndexService {
|
|
|
return size;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public Long downloadComponentData(Integer startFileIndex) {
|
|
|
- logger.info("正在下载器件数据...");
|
|
|
-
|
|
|
- // 清空data文件夹
|
|
|
- File dataDir = new File(SearchConstants.COMPONENT_DATA_DIR);
|
|
|
- // 若startFileIndex无意义,全部重新下载
|
|
|
- if (startFileIndex == null || startFileIndex < 1) {
|
|
|
- if (dataDir.isDirectory()) {
|
|
|
- clearDir(dataDir);
|
|
|
- }
|
|
|
- }
|
|
|
- if (!dataDir.exists()) {
|
|
|
- dataDir.mkdir();
|
|
|
- }
|
|
|
-
|
|
|
- Long size = 0L;
|
|
|
- PageParams params = new PageParams();
|
|
|
- int page = 1;
|
|
|
- // 重新计算开始的页码
|
|
|
- if (startFileIndex != null && startFileIndex >= 1) {
|
|
|
- page = SINGLE_FILE_MAX_SIZE / PAGE_SIZE * (startFileIndex - 1) + 1;
|
|
|
- }
|
|
|
- params.setCount(PAGE_SIZE);
|
|
|
- params.setPage(page);
|
|
|
-
|
|
|
- // 分页获取component数据
|
|
|
- PageInfo info = new PageInfo(params);
|
|
|
- Page<ComponentSimpleInfo> pageResult = componentDao.findAll(info);
|
|
|
- long totalElements = pageResult.getTotalElements();
|
|
|
- int fileIndex = 1;
|
|
|
- // 重新计算已下载的数据大小
|
|
|
- if (startFileIndex != null && startFileIndex >= 1) {
|
|
|
- size = Math.min(SINGLE_FILE_MAX_SIZE * (startFileIndex - 1), totalElements);
|
|
|
- fileIndex = startFileIndex;
|
|
|
- }
|
|
|
- logger.info("Number of components: " + totalElements);
|
|
|
-
|
|
|
- PrintWriter printWriter = null;
|
|
|
- try {
|
|
|
- String dataFilePath = SearchConstants.COMPONENT_DATA_DIR + "component_" + fileIndex + ".json";
|
|
|
- if(totalElements > size){
|
|
|
- printWriter = new PrintWriter(dataFilePath);
|
|
|
- logger.info("Writing data into " + dataFilePath);
|
|
|
- }
|
|
|
- int dataCount = 0;
|
|
|
- while (totalElements > size) {
|
|
|
- // 一个文件存放SINGLE_FILE_MAX_SIZE条数据,一旦超过,写入新的文件
|
|
|
- if (dataCount >= SINGLE_FILE_MAX_SIZE) {
|
|
|
- printWriter.flush();
|
|
|
- printWriter.close();
|
|
|
- dataCount = 0;
|
|
|
- dataFilePath = SearchConstants.COMPONENT_DATA_DIR + "component_" + (++fileIndex) + ".json";
|
|
|
- printWriter = new PrintWriter(dataFilePath);
|
|
|
- logger.info("Writing data into " + dataFilePath);
|
|
|
- }
|
|
|
-
|
|
|
- // 获取数据并写入文件
|
|
|
- List<ComponentSimpleInfo> components = pageResult.getContent();
|
|
|
- for (ComponentSimpleInfo component : components) {
|
|
|
- // 属性值的value为空,不写入索引
|
|
|
- Set<PropertyValueSimpleInfo> properties = component.getProperties();
|
|
|
- Set<PropertyValueSimpleInfo> removingProperties = new HashSet<>();
|
|
|
- for (PropertyValueSimpleInfo property : properties) {
|
|
|
- if (StringUtils.isEmpty(property.getValue())) {
|
|
|
- removingProperties.add(property);
|
|
|
- }
|
|
|
- }
|
|
|
- properties.removeAll(removingProperties);
|
|
|
- component.setProperties(properties);
|
|
|
- printWriter.println(JSONObject.toJSONString(component));
|
|
|
- }
|
|
|
- size += components.size();
|
|
|
- dataCount += components.size();
|
|
|
-
|
|
|
- // 打印器件数据的下载进度(百分比)
|
|
|
- if (size % 10000 == 0) {
|
|
|
- logger.info(String.format("Downloading...............%.2f%%", (size * 100.0 / totalElements)));
|
|
|
- }
|
|
|
-
|
|
|
- page++;
|
|
|
- params.setPage(page);
|
|
|
- info = new PageInfo(params);
|
|
|
- pageResult = componentDao.findAll(info);
|
|
|
- }
|
|
|
- } catch (FileNotFoundException e) {
|
|
|
- e.printStackTrace();
|
|
|
- } finally {
|
|
|
- if (printWriter != null) {
|
|
|
- printWriter.close();
|
|
|
- }
|
|
|
- }
|
|
|
- return size;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 创建器件索引,从数据库取数据
|
|
|
*
|
|
|
* @return 写入的器件索引数
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
- private Long createComponentIndexesFromDatabase() throws IOException {
|
|
|
+ public Long createComponentIndexs() throws IOException {
|
|
|
logger.info("正在创建器件索引...");
|
|
|
Long size = 0L;
|
|
|
PageParams params = new PageParams();
|
|
|
@@ -350,9 +239,9 @@ public class IndexServiceImpl implements IndexService {
|
|
|
|
|
|
// 器件索引的创建进度(百分比)
|
|
|
double indexProgress = size * 100.0 / totalElements;
|
|
|
- // 每创建0.3%,提交一次,避免内存耗尽,发生OutOfMemoryError
|
|
|
- if (indexProgress - recordProgress > 0.3) {
|
|
|
- logger.info(String.format("Component indexed...............%.2f%%", indexProgress));
|
|
|
+ System.out.printf("Component indexed...................%.2f%%\n", indexProgress);
|
|
|
+ // 每创建5%,提交一次,避免内存耗尽,发生OutOfMemoryError
|
|
|
+ if (indexProgress - recordProgress > 5) {
|
|
|
indexWriter.commit();
|
|
|
recordProgress = indexProgress;
|
|
|
}
|
|
|
@@ -374,15 +263,16 @@ public class IndexServiceImpl implements IndexService {
|
|
|
*/
|
|
|
private Document toDocument(KindSimpleInfo kind) {
|
|
|
if (kind == null || kind.getId() == null || StringUtils.isEmpty(kind.getNameCn()) || kind.getIsLeaf() == null
|
|
|
- || kind.getLevel() == null || StringUtils.isEmpty(kind.getRowid())) {
|
|
|
+ || kind.getLevel() == null) {
|
|
|
return null;
|
|
|
}
|
|
|
Document document = new Document();
|
|
|
+ // 不能用LongField,否则后续实时更新索引时,方法updateDocument(new Term("", ""),
|
|
|
+ // doc)无法根据id进行更新
|
|
|
document.add(new StringField(SearchConstants.KIND_ID_FIELD, String.valueOf(kind.getId()), Store.YES));
|
|
|
document.add(new TextField(SearchConstants.KIND_NAMECN_FIELD, kind.getNameCn(), Store.YES));
|
|
|
document.add(new StringField(SearchConstants.KIND_ISLEAF_FIELD, String.valueOf(kind.getIsLeaf()), Store.YES));
|
|
|
document.add(new StringField(SearchConstants.KIND_LEVEL_FIELD, String.valueOf(kind.getLevel()), Store.YES));
|
|
|
- document.add(new StringField(SearchConstants.KIND_ROWID_FIELD, kind.getRowid(), Store.YES));
|
|
|
return document;
|
|
|
}
|
|
|
|
|
|
@@ -394,18 +284,20 @@ public class IndexServiceImpl implements IndexService {
|
|
|
*/
|
|
|
private Document toDocument(BrandSimpleInfo brand) {
|
|
|
if (brand == null || brand.getId() == null || StringUtils.isEmpty(brand.getNameCn())
|
|
|
- || StringUtils.isEmpty(brand.getUuid()) || StringUtils.isEmpty(brand.getRowid())) {
|
|
|
+ || StringUtils.isEmpty(brand.getUuid())) {
|
|
|
return null;
|
|
|
}
|
|
|
Document document = new Document();
|
|
|
document.add(new StringField(SearchConstants.BRAND_ID_FIELD, String.valueOf(brand.getId()), Store.YES));
|
|
|
- document.add(new TextField(SearchConstants.BRAND_NAMECN_FIELD, brand.getNameCn(), Store.YES));
|
|
|
+ String nameCn = brand.getNameCn();
|
|
|
+ if (!StringUtils.isEmpty(nameCn)) {
|
|
|
+ document.add(new TextField(SearchConstants.BRAND_NAMECN_FIELD, nameCn, Store.YES));
|
|
|
+ }
|
|
|
String nameEn = brand.getNameEn();
|
|
|
if (!StringUtils.isEmpty(nameEn)) {
|
|
|
document.add(new TextField(SearchConstants.BRAND_NAMEEN_FIELD, nameEn, Store.YES));
|
|
|
}
|
|
|
document.add(new StringField(SearchConstants.BRAND_UUID_FIELD, brand.getUuid(), Store.YES));
|
|
|
- document.add(new StringField(SearchConstants.BRAND_ROWID_FIELD, brand.getRowid(), Store.YES));
|
|
|
return document;
|
|
|
}
|
|
|
|
|
|
@@ -418,7 +310,7 @@ public class IndexServiceImpl implements IndexService {
|
|
|
private Document toDocument(ComponentSimpleInfo component) {
|
|
|
if (component == null || component.getId() == null || StringUtils.isEmpty(component.getUuid())
|
|
|
|| StringUtils.isEmpty(component.getCode()) || component.getKindid() == null
|
|
|
- || component.getBrandid() == null || StringUtils.isEmpty(component.getRowid())) {
|
|
|
+ || component.getBrandid() == null) {
|
|
|
return null;
|
|
|
}
|
|
|
Document document = new Document();
|
|
|
@@ -431,21 +323,11 @@ public class IndexServiceImpl implements IndexService {
|
|
|
Store.YES));
|
|
|
document.add(new StringField(SearchConstants.COMPONENT_BRANDID_FIELD, String.valueOf(component.getBrandid()),
|
|
|
Store.YES));
|
|
|
- document.add(new StringField(SearchConstants.COMPONENT_ROWID_FIELD, component.getRowid(), Store.YES));
|
|
|
|
|
|
// 属性值加入索引,索引中field的键:"pr_"前缀连接属性的id
|
|
|
- Set<PropertyValueSimpleInfo> propertyValues = component.getProperties();
|
|
|
- StringBuilder stringBuilder = new StringBuilder();
|
|
|
- for (PropertyValueSimpleInfo propertyValue : propertyValues) {
|
|
|
+ Set<PropertyValue> propertyValues = component.getProperties();
|
|
|
+ for (PropertyValue propertyValue : propertyValues) {
|
|
|
if (!StringUtils.isEmpty(propertyValue.getValue())) {
|
|
|
- /*
|
|
|
- * 将属性值每行记录的rowid拼接在一起建立索引, 用于实时更新索引服务中 (属性值记录被删除时,
|
|
|
- * 无法根据DCN返回的属性值记录的rowid,得知需要更新哪个器件的索引),
|
|
|
- * 通过该rowid,从本地索引中获得相应器件的rowid, 再根据该rowid从数据库中获取器件信息, 更新本地索引
|
|
|
- */
|
|
|
- // 将rowid中的符号+和空格替换为_,并以空格将rowid隔开
|
|
|
- stringBuilder.append(propertyValue.getRowid().replaceAll("[ +]+", "_")).append(" ");
|
|
|
-
|
|
|
String fieldKey = SearchConstants.COMPONENT_PROPERTY_PREFIX + propertyValue.getPropertyid();
|
|
|
document.add(new StringField(fieldKey, propertyValue.getValue(), Store.YES));
|
|
|
|
|
|
@@ -454,31 +336,28 @@ public class IndexServiceImpl implements IndexService {
|
|
|
document.add(new TextField(fieldKeyTokenized, propertyValue.getValue(), Store.YES));
|
|
|
}
|
|
|
}
|
|
|
- if (!StringUtils.isEmpty(stringBuilder.toString())) {
|
|
|
- document.add(new TextField(SearchConstants.COMPONENT_PROPERTY_ROWIDS_FIELD, stringBuilder.toString(),
|
|
|
- Store.YES));
|
|
|
- }
|
|
|
return document;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 清空文件夹
|
|
|
+ * 删除原有索引文件
|
|
|
*
|
|
|
- * @param dir
|
|
|
+ * @param file
|
|
|
*/
|
|
|
- private void clearDir(File dir) {
|
|
|
- if (dir == null) {
|
|
|
+ private void deleteOldIndex(File file) {
|
|
|
+ if (file == null) {
|
|
|
return;
|
|
|
}
|
|
|
- if (dir.isDirectory()) {
|
|
|
- File[] files = dir.listFiles();
|
|
|
+ if (file.isDirectory()) {
|
|
|
+ File[] files = file.listFiles();
|
|
|
for (File f : files) {
|
|
|
- clearDir(f);
|
|
|
+ deleteOldIndex(f);
|
|
|
}
|
|
|
}
|
|
|
- dir.delete();
|
|
|
+
|
|
|
+ file.delete();
|
|
|
try {
|
|
|
- logger.info("Deleted " + dir.getCanonicalPath());
|
|
|
+ logger.info("deleted " + file.getCanonicalPath());
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
@@ -487,9 +366,9 @@ public class IndexServiceImpl implements IndexService {
|
|
|
@Override
|
|
|
public void save(Object obj) {
|
|
|
if (obj == null) {
|
|
|
- logger.error("实时更新对象为空");
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
try {
|
|
|
indexWriter = indexWriterManager.get();
|
|
|
if (obj instanceof KindSimpleInfo) {
|
|
|
@@ -518,13 +397,12 @@ public class IndexServiceImpl implements IndexService {
|
|
|
} finally {
|
|
|
indexWriterManager.release();
|
|
|
}
|
|
|
- logger.info("Saved object... " + obj + "\n");
|
|
|
+ logger.info("saved object... " + obj + "\n");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void update(Object obj) {
|
|
|
if (obj == null) {
|
|
|
- logger.error("实时更新对象为空");
|
|
|
return;
|
|
|
}
|
|
|
try {
|
|
|
@@ -533,20 +411,22 @@ public class IndexServiceImpl implements IndexService {
|
|
|
KindSimpleInfo kind = (KindSimpleInfo) obj;
|
|
|
Document document = toDocument(kind);
|
|
|
if (document != null) {
|
|
|
- indexWriter.updateDocument(new Term(SearchConstants.KIND_ROWID_FIELD, kind.getRowid()), document);
|
|
|
+ indexWriter.updateDocument(new Term(SearchConstants.KIND_ID_FIELD, String.valueOf(kind.getId())),
|
|
|
+ document);
|
|
|
}
|
|
|
} else if (obj instanceof BrandSimpleInfo) {
|
|
|
BrandSimpleInfo brand = (BrandSimpleInfo) obj;
|
|
|
Document document = toDocument((BrandSimpleInfo) obj);
|
|
|
if (document != null) {
|
|
|
- indexWriter.updateDocument(new Term(SearchConstants.BRAND_ROWID_FIELD, brand.getRowid()), document);
|
|
|
+ indexWriter.updateDocument(new Term(SearchConstants.BRAND_ID_FIELD, String.valueOf(brand.getId())),
|
|
|
+ document);
|
|
|
}
|
|
|
} else if (obj instanceof ComponentSimpleInfo) {
|
|
|
ComponentSimpleInfo component = (ComponentSimpleInfo) obj;
|
|
|
Document document = toDocument(component);
|
|
|
if (document != null) {
|
|
|
- indexWriter.updateDocument(new Term(SearchConstants.COMPONENT_ROWID_FIELD, component.getRowid()),
|
|
|
- document);
|
|
|
+ indexWriter.updateDocument(
|
|
|
+ new Term(SearchConstants.COMPONENT_ID_FIELD, String.valueOf(component.getId())), document);
|
|
|
}
|
|
|
} else {
|
|
|
logger.error("message parsing failed!");
|
|
|
@@ -559,26 +439,25 @@ public class IndexServiceImpl implements IndexService {
|
|
|
} finally {
|
|
|
indexWriterManager.release();
|
|
|
}
|
|
|
- logger.info("Updated object... " + obj + "\n");
|
|
|
+ logger.info("updated object... " + obj + "\n");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void delete(Object obj) {
|
|
|
if (obj == null) {
|
|
|
- logger.error("实时更新对象为空");
|
|
|
return;
|
|
|
}
|
|
|
try {
|
|
|
indexWriter = indexWriterManager.get();
|
|
|
if (obj instanceof KindSimpleInfo) {
|
|
|
- indexWriter
|
|
|
- .deleteDocuments(new Term(SearchConstants.KIND_ROWID_FIELD, ((KindSimpleInfo) obj).getRowid()));
|
|
|
+ indexWriter.deleteDocuments(
|
|
|
+ new Term(SearchConstants.KIND_ID_FIELD, ((KindSimpleInfo) obj).getId().toString()));
|
|
|
} else if (obj instanceof BrandSimpleInfo) {
|
|
|
indexWriter.deleteDocuments(
|
|
|
- new Term(SearchConstants.BRAND_ROWID_FIELD, ((BrandSimpleInfo) obj).getRowid()));
|
|
|
+ new Term(SearchConstants.BRAND_ID_FIELD, ((BrandSimpleInfo) obj).getId().toString()));
|
|
|
} else if (obj instanceof ComponentSimpleInfo) {
|
|
|
indexWriter.deleteDocuments(
|
|
|
- new Term(SearchConstants.COMPONENT_ROWID_FIELD, ((ComponentSimpleInfo) obj).getRowid()));
|
|
|
+ new Term(SearchConstants.COMPONENT_ID_FIELD, ((ComponentSimpleInfo) obj).getId().toString()));
|
|
|
} else {
|
|
|
logger.error("message parsing failed!");
|
|
|
}
|
|
|
@@ -590,6 +469,6 @@ public class IndexServiceImpl implements IndexService {
|
|
|
} finally {
|
|
|
indexWriterManager.release();
|
|
|
}
|
|
|
- logger.info("Deleted object... " + obj + "\n");
|
|
|
+ logger.info("deleted object... " + obj + "\n");
|
|
|
}
|
|
|
}
|