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

searchContext not returning requested search results

    Details

      Description

      Use the following code

      String defaultAssetcategoryIds = "1693623,1693624,1693625";
      
      List<Document> documents = null;
      SearchContext searchContext = SearchContextFactory.getInstance(origrequest);
      searchContext.setCompanyId(themeDisplay.getCompanyId());
      searchContext.setGroupIds(new long[] {themeDisplay.getScopeGroupId()});
      searchContext.setLocale(themeDisplay.getLocale());
      searchContext.setTimeZone(themeDisplay.getTimeZone());
      searchContext.setKeywords(q);
      						 	
      searchContext.setAssetCategoryIds(StringUtil.split(defaultAssetcategoryIds,0L));
      						 
      searchContext.setEnd(20);
      searchContext.setStart(0);
      String[] entryCalssName = {JournalArticle.class.getName()};
      searchContext.setEntryClassNames(entryCalssName);
      						
      Hits hits = indexer.search(searchContext);
      documents = hits.toList();

      in a portlet and notice that ALL documents return and not just the ones specified via AssetCategoryIds.

      NOTE: Categories will need to be created and their IDs will need to be played in defaultAssetcategoryIds

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  6 years, 8 weeks ago

                  Packages

                  Version Package
                  6.1.2 CE GA3
                  6.1.30 EE GA3
                  6.2.0 CE M6