| | |
| | | indexWriter.addDocuments(docs); |
| | | indexWriter.commit(); |
| | | } catch (IOException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | |
| | | file.delete(); |
| | | } |
| | | |
| | | |
| | | /* |
| | | public void createdIndex(FieldSetEntity fse) throws IOException { |
| | | String function_uuid=fse.getString("function_uuid"); |
| | | String service_uuid=fse.getString("service_uuid"); |
| | | |
| | | //è·åå
¨ææ£ç´¢é
ç½® |
| | | FieldSetEntity fseConfig=baseDao.getFieldSetEntityByFilter("product_sys_document_search", "function_uuid=?", new Object[] {function_uuid}, false); |
| | | if (fseConfig!=null) { |
| | | String table_uuid=fseConfig.getString("table_name"); |
| | | String attachment_field=fseConfig.getString("attachment_file"); |
| | | |
| | | //è·åç¼å表é
ç½® |
| | | FieldSetEntity fseTable=baseDao.getFieldSetEntity("product_sys_datamodel_table", table_uuid, false); |
| | | if (fseTable!=null) { |
| | | |
| | | //è·ååæ°æ® |
| | | FieldSetEntity fseService=baseDao.getFieldSetEntityBySQL("SELECT * FROM "+fseTable.getString("table_name")+" WHERE uuid=?", new Object[] {service_uuid}, false); |
| | | if (fseService!=null) { |
| | | |
| | | //è·åéä»¶uuids |
| | | String attachments=fseService.getString(attachment_field); |
| | | if (!StringUtils.isEmpty(attachments)) { |
| | | |
| | | //éåè·åéä»¶ä¿¡æ¯ |
| | | String [] attachment=attachments.split(","); |
| | | List<Document> docs=new ArrayList<>(); |
| | | for (int i = 0; i < attachment.length; i++) { |
| | | |
| | | //è·åéä»¶ä¿¡æ¯ |
| | | FieldSetEntity fseAttachment=baseDao.getFieldSetEntity("product_sys_attachments", attachment[i], false); |
| | | if (fseAttachment!=null) { |
| | | //è·åéä»¶ |
| | | File file=fileManagerService.getFile(attachment[i]); |
| | | if (file!=null) { |
| | | //çæç´¢å¼ä¿¡æ¯ |
| | | Document doc=new Document(); |
| | | doc.add(new StringField("uuid", attachment[i], Field.Store.YES)); //éä»¶UUID |
| | | doc.add(new TextField("service_uuid", service_uuid, Field.Store.YES)); //ä¸å¡UUID |
| | | doc.add(new TextField("function_uuid", function_uuid, Field.Store.YES)); //å
±å¯é£ä¸ªUUID |
| | | doc.add(new TextField("file_name", fseAttachment.getString("file_name"), Field.Store.YES)); //æä»¶å |
| | | doc.add(new TextField("file_content", FileUtils.FileToString(file), Field.Store.YES)); //æä»¶å
å
容 |
| | | docs.add(doc); |
| | | } |
| | | file.delete(); |
| | | } |
| | | } |
| | | //åå
¥ç´¢å¼ |
| | | indexWriter.addDocuments(docs); |
| | | indexWriter.commit(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | */ |
| | | |
| | | /** |
| | | * ææ¡£æ£ç´¢ |
| | |
| | | |
| | | //å页æ¥è¯¢ææ¡£ |
| | | TopDocs topDocs = searchByPage(fse.getInteger("cpage"), fse.getInteger("pagesize"), indexSearcher, query); |
| | | |
| | | |
| | | |
| | | ScoreDoc[] hits = topDocs.scoreDocs; |
| | | for (int i = 0; i < hits.length; i++) { |