Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-124605

BaseIndexer doesn't return all available locales from index

    Details

      Description

      Reproduction steps:

      1. Start up DXP
      2. Instance Settings > Localization > Set the default language of the portal to English - United Kingdom
      3. Create a Basic Web Content Article with the following translations: English-UK, Finnish, German
      4. Run the attached journal_translation.groovy in Control Panel, but replace the groupID with the actual groupID of the site
        import com.liferay.portal.kernel.search.Field;
        import com.liferay.portal.kernel.search.Indexer;
        import com.liferay.portal.kernel.search.IndexerRegistryUtil;
        import com.liferay.portal.kernel.search.SearchContext;
        import com.liferay.portal.kernel.search.SearchContextFactory;
        import com.liferay.portal.kernel.search.Hits;
        import com.liferay.portal.kernel.search.Document;
        import com.liferay.journal.model.JournalArticle;
        import com.liferay.portal.kernel.util.PortalUtil;
        import javax.servlet.http.HttpServletRequest;
        import com.liferay.portal.kernel.theme.ThemeDisplay;
        import com.liferay.portal.kernel.util.WebKeys;
        import java.util.Locale;
        
        HttpServletRequest httpRequest = PortalUtil.getOriginalServletRequest(PortalUtil.getHttpServletRequest(actionRequest));
        long[] groupids = new long[1];
        groupids[0] = 20124;
        Locale locale = new Locale("et", "EE");
        
        out.println("");
        out.println("Locale: " + locale);
        out.println("");
        
        Indexer indexer = IndexerRegistryUtil.getIndexer(JournalArticle.class);
        SearchContext searchContext = SearchContextFactory.getInstance(httpRequest);
        
        searchContext.setGroupIds(null);
        searchContext.setStart(0);
        searchContext.setEnd(10);
        searchContext.setGroupIds(groupids);
        
        Hits hits = indexer.search(searchContext);
        
        if (hits != null && hits.getLength() > 0) {
        	for (Document document : hits.getDocs()) {
        			String articleId = document.get("articleId");
        			out.println("ArticleId: " + articleId);
        			out.println("Content ----------");
        			for (Map.Entry<String, Field> entry : document.getFields().entrySet()) {
        				out.println("key: " + entry.getKey() + "  value: " + ((Field)entry.getValue()).getValue());
        
        			}
        			String content = document.get(locale, "content");
        			out.println("Content By Localace: " + content);
        			out.println("Content ----------");
        
        
        	}
        }
        

      Actual result: only Finnish and German translations are returned
      Expected result: all translations get returned

        Attachments

          Activity

            People

            Assignee:
            brian.lee Brian Lee
            Reporter:
            istvan.sajtos Istvan Sajtos
            Participants of an Issue:
            Recent user:
            Yunlin "Steven" Sun
            Engineering Assignee:
            Bryan Engler
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Days since last comment:
              40 weeks, 4 days ago
              Development End Date:
              Development Start Date:

                Packages

                Version Package
                7.2.10 DXP FP10
                7.2.10.4 DXP SP4
                7.2.X
                7.3.10 DXP FP1
                7.3.10.1 DXP SP1
                7.3.6 CE GA7
                7.3.X
                Master