Example usage for com.liferay.portal.kernel.search Field UID

List of usage examples for com.liferay.portal.kernel.search Field UID

Introduction

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

Prototype

String UID

To view the source code for com.liferay.portal.kernel.search Field UID.

Click Source Link

Usage

From source file:com.liferay.wiki.search.WikiNodeIndexer.java

License:Open Source License

public WikiNodeIndexer() {
    setDefaultSelectedFieldNames(Field.COMPANY_ID, Field.ENTRY_CLASS_NAME, Field.ENTRY_CLASS_PK, Field.UID);
    setFilterSearch(false);
    setPermissionAware(false);
}

From source file:com.liferay.wiki.search.WikiNodeIndexer.java

License:Open Source License

@Override
protected void doReindex(WikiNode wikiNode) throws Exception {
    Document document = getDocument(wikiNode);

    if (!wikiNode.isInTrash()) {
        IndexWriterHelperUtil.deleteDocument(getSearchEngineId(), wikiNode.getCompanyId(),
                document.get(Field.UID), isCommitImmediately());

        return;//from   w  w w  .  ja v a2  s .c  o  m
    }

    IndexWriterHelperUtil.updateDocument(getSearchEngineId(), wikiNode.getCompanyId(), document,
            isCommitImmediately());
}

From source file:com.liferay.wiki.search.WikiPageIndexer.java

License:Open Source License

public WikiPageIndexer() {
    setDefaultSelectedFieldNames(Field.ASSET_TAG_NAMES, Field.COMPANY_ID, Field.CONTENT, Field.ENTRY_CLASS_NAME,
            Field.ENTRY_CLASS_PK, Field.GROUP_ID, Field.MODIFIED_DATE, Field.SCOPE_GROUP_ID, Field.TITLE,
            Field.UID);
    setFilterSearch(true);//from ww  w . j  a  v a  2s  . c  o  m
    setPermissionAware(true);
}

From source file:com.vportal.portlet.vcms.util.SearchIndexer.java

License:Open Source License

public static String getEntryUID(long quesId) {
    Document doc = new DocumentImpl();
    doc.addUID(PORTLET_ID, quesId);/*  w w  w.j a  v a2 s.c  o m*/

    return doc.get(Field.UID);
}

From source file:jorgediazest.indexchecker.model.JournalArticle.java

License:Open Source License

@Override
public void fillDataObject(Data data, String[] attributes, Document doc) {
    super.fillDataObject(data, attributes, doc);

    if (indexAllVersions) {
        long id = DataUtil.getIdFromUID(doc.get(Field.UID));
        data.setPrimaryKey(id);/*w  w  w.j a va  2 s .  co  m*/
    }
}

From source file:org.rsc.liferay.solr.SolrIndexSearcher.java

License:Open Source License

protected String getSnippet(SolrDocument solrDocument, QueryConfig queryConfig, Set<String> queryTerms,
        Map<String, Map<String, List<String>>> highlights, String field) {

    if (highlights == null) {
        return StringPool.BLANK;
    }/*from w w w.j av  a 2 s  . c o  m*/

    String key = (String) solrDocument.getFieldValue(Field.UID);

    Map<String, List<String>> uidHighlights = highlights.get(key);

    boolean localizedSearch = true;

    String defaultLanguageId = LocaleUtil.toLanguageId(LocaleUtil.getDefault());
    String queryLanguageId = LocaleUtil.toLanguageId(queryConfig.getLocale());

    if (defaultLanguageId.equals(queryLanguageId)) {
        localizedSearch = false;
    }

    if (localizedSearch) {
        String localizedName = DocumentImpl.getLocalizedName(queryConfig.getLocale(), field);

        if (solrDocument.containsKey(localizedName)) {
            field = localizedName;
        }
    }

    List<String> snippets = uidHighlights.get(field);

    String snippet = StringUtil.merge(snippets, "...");

    if (Validator.isNotNull(snippet)) {
        snippet = snippet + "...";
    } else {
        snippet = StringPool.BLANK;
    }

    Pattern pattern = Pattern.compile("<em>(.*?)</em>");

    Matcher matcher = pattern.matcher(snippet);

    while (matcher.find()) {
        queryTerms.add(matcher.group(1));
    }

    snippet = StringUtil.replace(snippet, "<em>", "");
    snippet = StringUtil.replace(snippet, "</em>", "");

    return snippet;
}

From source file:org.xcolab.portlets.discussions.Indexer.java

License:Open Source License

public String getEntryUID(long entryId) {
    Document doc = new DocumentImpl();

    doc.addUID(PORTLET_ID, entryId);//from  www.  j  a v  a2s.c om

    return doc.get(Field.UID);
}

From source file:org.xcolab.portlets.search.Indexer.java

License:Open Source License

public static String getArticleUID(String articleId, boolean isOld) {
    Document doc = new DocumentImpl();

    if (isOld) {//from   ww  w.j a  v a 2  s .co  m
        doc.addUID(PORTLET_ID, articleId, "old");
    } else {
        doc.addUID(PORTLET_ID, articleId);
    }

    return doc.get(Field.UID);
}

From source file:org.xcolab.portlets.search.Indexer.java

License:Open Source License

@Override
public void reindex(Object obj) throws SearchException {

    JournalArticle article = (JournalArticle) obj;

    Document document = getDocument(article);

    if (!article.isIndexable()
            || (!article.isApproved() && (article.getVersion() != JournalArticleConstants.VERSION_DEFAULT))) {

        SearchEngineUtil.deleteDocument(getSearchEngineId(), article.getCompanyId(), document.get(Field.UID));

        return;//from  ww w . j a v  a 2s .c  o  m
    }

    SearchEngineUtil.deleteDocument(getSearchEngineId(), article.getCompanyId(), document.getUID());
    SearchEngineUtil.updateDocument(getSearchEngineId(), article.getCompanyId(), document);

}