@Override public String[] getSearchClassNames() { return new String[] {getClassName()}; }
protected String getClassName(SearchContext searchContext) { return getClassName(); }
@Override public boolean equals(Object object) { if (object == this) { return true; } if (!(object instanceof Indexer<?>)) { return false; } Indexer<?> indexer = (Indexer<?>)object; return Objects.equals(getClassName(), indexer.getClassName()); }
@Override public int hashCode() { return HashUtil.hash(0, getClassName()); }
@Override public boolean isIndexerEnabled() { if (_indexerEnabled == null) { String className = getClassName(); String indexerEnabled = PropsUtil.get( PropsKeys.INDEXER_ENABLED, new com.liferay.portal.kernel.configuration.Filter(className)); _indexerEnabled = GetterUtil.getBoolean(indexerEnabled, true); return _indexerEnabled; } return _indexerEnabled; }
@Override public void reindex(Collection<T> collection) { if (IndexWriterHelperUtil.isIndexReadOnly() || IndexWriterHelperUtil.isIndexReadOnly(getClassName()) || !isIndexerEnabled() || collection.isEmpty()) { return; } for (T element : collection) { try { reindex(element); } catch (SearchException se) { _log.error("Unable to index object: " + element, se); } } }
protected void deleteDocument(long companyId, String field1) throws Exception { Document document = new DocumentImpl(); document.addUID(getClassName(), field1); IndexWriterHelperUtil.deleteDocument( getSearchEngineId(), companyId, document.get(Field.UID), _commitImmediately); }
protected void deleteDocument(long companyId, String field1, String field2) throws Exception { Document document = new DocumentImpl(); document.addUID(getClassName(), field1, field2); IndexWriterHelperUtil.deleteDocument( getSearchEngineId(), companyId, document.get(Field.UID), _commitImmediately); }
@Override public void reindex(T object) throws SearchException { try { if (IndexWriterHelperUtil.isIndexReadOnly() || IndexWriterHelperUtil.isIndexReadOnly(getClassName()) || !isIndexerEnabled()) { return; } if (object == null) { return; } doReindex(object); } catch (SearchException se) { throw se; } catch (Exception e) { throw new SearchException(e); } }
@Override public void reindex(String className, long classPK) throws SearchException { try { if (IndexWriterHelperUtil.isIndexReadOnly() || IndexWriterHelperUtil.isIndexReadOnly(getClassName()) || !isIndexerEnabled() || (classPK <= 0)) { return; } doReindex(className, classPK); } catch (NoSuchModelException nsme) { if (_log.isWarnEnabled()) { _log.warn( StringBundler.concat( "Unable to index ", className, " ", String.valueOf(classPK)), nsme); } } catch (SearchException se) { throw se; } catch (Exception e) { throw new SearchException(e); } }
@Override public void reindex(String[] ids) throws SearchException { long companyThreadLocalCompanyId = CompanyThreadLocal.getCompanyId(); try { if (IndexWriterHelperUtil.isIndexReadOnly() || IndexWriterHelperUtil.isIndexReadOnly(getClassName()) || !isIndexerEnabled()) { return; } if (ids.length > 0) { long companyId = GetterUtil.getLong(ids[0]); CompanyThreadLocal.setCompanyId(companyId); } doReindex(ids); } catch (SearchException se) { throw se; } catch (Exception e) { throw new SearchException(e); } finally { CompanyThreadLocal.setCompanyId(companyThreadLocalCompanyId); } }