loadIndex();
}
@Override
public void updateIndex(Long pageId) {
PageEntity page = getDao().getPageDao().getById(pageId);
if (page == null) {
return;
}
refreshIndex();
List<PageEntity> versions = getDao().getPageDao().selectByUrl(
page.getFriendlyURL());
for (PageEntity version : versions) {
removeFromIndex(version.getId());
}
page = getDao().getPageDao().getByUrl(page.getFriendlyURL());
if (page == null) {
return;
}
if (!page.isSearchable()) {
return;
}
String content = getDao().getPageDao().getContent(page.getId(),
getLanguage());
if (content == null) {
return;
}
String data = StrUtil.extractSearchTextFromHTML(content.toLowerCase());
String[] words = StrUtil.splitByWord(data);
//logger.info(Arrays.asList(words));
for (String word : words) {
if (word.length() < 3) {
continue;
}
if (!getIndex().containsKey(word)) {
getIndex().put(word, new HashSet<Long>());
}
if (!getIndex().get(word).contains(page.getId())) {
getIndex().get(word).add(page.getId());
}
}
}