Example usage for com.liferay.portal.kernel.search DocumentComparator DocumentComparator

List of usage examples for com.liferay.portal.kernel.search DocumentComparator DocumentComparator

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.search DocumentComparator DocumentComparator.

Prototype

public DocumentComparator(boolean ascending, boolean caseSensitive) 

Source Link

Usage

From source file:com.rivetlogic.portal.search.elasticsearch.ElasticsearchIndexWriterImpl.java

License:Open Source License

public void addDocuments(SearchContext searchContext, Collection<Document> documents) throws SearchException {
    if (_log.isDebugEnabled()) {
        _log.debug("Add documents for elasticsearch indexing");
    }//from  w ww.j  ava 2  s  . co  m
    /** This is to sort the Documents with version field from oldest to latest updates to
    retain the modifications */
    DocumentComparator documentComparator = new DocumentComparator(true, false);
    documentComparator.addOrderBy(ElasticsearchIndexerConstants.VERSION);
    Collections.sort((List<Document>) documents, documentComparator);

    for (Document document : documents) {
        updateDocument(searchContext, document);
    }
}

From source file:com.rivetlogic.portal.search.elasticsearch.ElasticsearchIndexWriterImpl.java

License:Open Source License

public void updateDocuments(SearchContext searchContext, Collection<Document> documents)
        throws SearchException {

    /** This is to sort the Documents with version field from oldest to latest updates to
    retain the modifications *//*  w  ww  .  jav  a  2  s. c  om*/
    DocumentComparator documentComparator = new DocumentComparator(true, false);
    documentComparator.addOrderBy(ElasticsearchIndexerConstants.VERSION);
    Collections.sort((List<Document>) documents, documentComparator);

    for (Document document : documents) {
        updateDocument(searchContext, document);
    }
}