List<FileHeader> result = new ArrayList<FileHeader>();
try {
CommonsHttpSolrServer solr = new CommonsHttpSolrServer(getConfiguration().getString("solr.url"));
- SolrQuery solrQuery = new SolrQuery(query);
+ SolrQuery solrQuery = new SolrQuery(escapeCharacters(normalizeSearchQuery(query)));
QueryResponse response = solr.query(solrQuery);
SolrDocumentList results = response.getResults();
User user = getUser(userId);
}
@Override
+ public void refreshSolrIndex() {
+ try {
+ CommonsHttpSolrServer solr = new CommonsHttpSolrServer(getConfiguration().getString("solr.url"));
+
+ List<Long> fileIds = dao.getAllFileIds();
+ for (Long id : fileIds) {
+ postFileToSolr(id);
+ }
+ solr.optimize();
+ solr.commit();
+ } catch (IOException e) {
+ throw new EJBException(e);
+ } catch (SolrServerException e) {
+ throw new EJBException(e);
+ }
+ }
+
+ @Override
public FileHeaderDTO createFile(Long userId, Long folderId, String name, String mimeType, long fileSize, String filePath)
throws DuplicateNameException, ObjectNotFoundException, GSSIOException,
InsufficientPermissionsException, QuotaExceededException {
result.append(filename);
return result.toString();
}
+
+ private String normalizeSearchQuery(String query) {
+ if (query.contains("*"))
+ return query.toLowerCase().replace('ά', 'α').replace('έ', 'ε').replace('ί', 'ι').replace('ή', 'η').replace('ύ', 'υ')
+ .replace('ό', 'ο').replace('ς', 'σ').replace('ώ', 'ω').replace('ϊ', 'ι').replace('ϋ', 'υ');
+ else
+ return query;
+ }
+
+ private String escapeCharacters(String text) {
+ return text.replaceAll(":", "\\\\:");
+ }
}