Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7514545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:31:45+00:00 2026-05-30T00:31:45+00:00

i’d like to implement a index on a custom asset made for my project

  • 0

i’d like to implement a index on a custom asset made for my project called “projet”, i’ve already developped this class : (based on the liferay’s bookmark indexer )

    /**
     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
     *
     * This library is free software; you can redistribute it and/or modify it under
     * the terms of the GNU Lesser General Public License as published by the Free
     * Software Foundation; either version 2.1 of the License, or (at your option)
     * any later version.
     *
     * This library is distributed in the hope that it will be useful, but WITHOUT
     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
     * details.
     */



    import java.util.ArrayList;
    import java.util.Collection;
    import java.util.List;
    import java.util.Locale;

    import javax.portlet.PortletURL;

    import org.apache.log4j.Logger;

    import com.liferay.portal.kernel.search.BaseIndexer;
    import com.liferay.portal.kernel.search.BooleanQuery;
    import com.liferay.portal.kernel.search.Document;
    import com.liferay.portal.kernel.search.Field;
    import com.liferay.portal.kernel.search.Indexer;
    import com.liferay.portal.kernel.search.SearchContext;
    import com.liferay.portal.kernel.search.SearchEngineUtil;
    import com.liferay.portal.kernel.search.Summary;
    import com.liferay.portal.kernel.util.GetterUtil;
    import com.liferay.portal.model.Group;
    import com.liferay.portal.service.ClassNameLocalServiceUtil;
    import com.liferay.portal.service.GroupLocalServiceUtil;
    import com.liferay.portal.util.PortletKeys;




    public class ProjetIndexer extends BaseIndexer {
    private static Logger LOGGER = Logger.getLogger(ProjetIndexer.class);

    public static final String[] CLASS_NAMES = { Projet.class.getName() };

    public String[] getClassNames() {
        return CLASS_NAMES;
    }


    public String getPortletId() {
        return Long.toString(ClassNameLocalServiceUtil.getClassNameId(Projet.class)) ;
    }

    @Override
    protected void doDelete(Object obj) throws Exception {
        LOGGER.info("doDelete");

        Projet entry = (Projet) obj;

        deleteDocument(entry.getCompanyId(), entry.getPrimaryKey());

    }

    @Override
    protected Document doGetDocument(Object obj) throws Exception {
        LOGGER.info("doGetDocument");

        Projet entry = (Projet) obj;

        Document document = getBaseModelDocument(getPortletId(), entry);

        document.addText(Field.DESCRIPTION, "test123");
        document.addText(Field.TITLE,  "test123");
        document.addKeyword(Field.TYPE, entry.getType());
        document.addKeyword(Field.COMPANY_ID, entry.getCompanyId());


        //what else ??




        return document;
    }

    @Override
    protected Summary doGetSummary(Document document, Locale locale,
            String snippet, PortletURL portletURL) throws Exception {


LOGGER.info("doGetSummary");


        String title = document.get(Field.TITLE);

        String url = document.get(Field.URL);

        String entryId = document.get(Field.ENTRY_CLASS_PK);

        // portletURL.setParameter("struts_action",
        // "/bookmarks/view_entry");TODO
        portletURL.setParameter("entryId", entryId);

        return new Summary(title, url, portletURL);

    }

    @Override
    protected void doReindex(Object obj) throws Exception {
        LOGGER.info("doReindex");

        Projet entry = (Projet) obj;

        Document document = getDocument(entry);

        SearchEngineUtil.updateDocument(entry.getCompanyId(), document);

    }

    @Override
    protected void doReindex(String className, long classPK) throws Exception {
        LOGGER.info("doReindex");

        Projet entry = ProjetLocalServiceUtil.getProjet(classPK);

        doReindex(entry);

    }

    @Override
    protected void doReindex(String[] ids) throws Exception {
        long companyId = GetterUtil.getLong(ids[0]);

        LOGGER.info("doReindex");

        // reindexFolders(companyId);
        reindexRoot(companyId);

    }

    @Override
    protected String getPortletId(SearchContext searchContext) {
        return getPortletId();
    }


    protected void reindexRoot(long companyId) throws Exception {

        LOGGER.info("reindexRoot");

        int groupCount = GroupLocalServiceUtil.getCompanyGroupsCount(companyId);

        int groupPages = groupCount / Indexer.DEFAULT_INTERVAL;

        for (int i = 0; i <= groupPages; i++) {
            int groupStart = (i * Indexer.DEFAULT_INTERVAL);
            int groupEnd = groupStart + Indexer.DEFAULT_INTERVAL;

            reindexRoot(companyId, groupStart, groupEnd);
        }
    }

    protected void reindexRoot(long companyId, int groupStart, int groupEnd)
            throws Exception {

        LOGGER.info("reindexRoot");

        List<Group> groups = GroupLocalServiceUtil.getCompanyGroups(companyId,
                groupStart, groupEnd);

        for (Group group : groups) {
            long groupId = group.getGroupId();
            // long folderId =
            // BookmarksFolderConstants.DEFAULT_PARENT_FOLDER_ID;

            int entryCount = ProjetLocalServiceUtil.getEntriesCount(groupId);

            int entryPages = entryCount / Indexer.DEFAULT_INTERVAL;

            for (int i = 0; i <= entryPages; i++) {
                int entryStart = (i * Indexer.DEFAULT_INTERVAL);
                int entryEnd = entryStart + Indexer.DEFAULT_INTERVAL;

                reindexEntries(companyId, groupId, entryStart, entryEnd);
            }
        }
    }


    protected void reindexEntries(long companyId, long groupId, int entryStart,
            int entryEnd) throws Exception {

        LOGGER.info("reindexEntries");

        List<Projet> entries = ProjetLocalServiceUtil.getEntries(groupId,
                entryStart, entryEnd);

        if (entries.isEmpty()) {
            return;
        }

        Collection<Document> documents = new ArrayList<Document>();

        for (Projet entry : entries) {
            Document document = getDocument(entry);

            documents.add(document);
        }

        SearchEngineUtil.updateDocuments(companyId, documents);
    }
}

and this is my liferay portlet.xml:

<indexer-class>path package .ProjetIndexer</indexer-class>   

but it doesnt work. search portlet (bundled with liferay 6.0) does not retrieve my custom asset

any ideas? thank

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T00:31:46+00:00Added an answer on May 30, 2026 at 12:31 am

    My issue is solved by deleting data under /data/lucent/ Maybe my tests deleloppment was corrupted I’ve changed the method doGetDocument too, making sure that no empty field is set in the map. many thanks for your cooperation

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
I would like to count the length of a string with PHP. The string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
this is what i have right now Drawing an RSS feed into the php,
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.