1

I am using liferay6.2. I uploaded a Word file in document and media. If I am searching for a word like example, "stack overflow" which occurs in 10 places in the document. I'm getting only the first three occurrences. How do I get all occurrences in the file? For this I tried following

    SearchContext searchContext = SearchContextFactory.getInstance(request);
            searchContext.setKeywords(keywords);
    
        QueryConfig queryConfig = new QueryConfig();
            queryConfig.setHighlightEnabled(true);
    
        searchContext.setQueryConfig(queryConfig);
    
        MultiValueFacet xhtmlFacet = new MultiValueFacet(searchContext);
            xhtmlFacet.setFieldName("extension");
            String[] extensions = {"docx"};     
            xhtmlFacet.setValues(extensions);
       searchContext.addFacet(xhtmlFacet);
    
    Indexer indexer = IndexerRegistryUtil.getIndexer("com.liferay.portlet.documentlibrary.model.DLFileEntry");
Hits hits = indexer.search(searchContext);  
    PortletURL portleturl1 = PortletURLFactoryUtil.create(request, themeDisplay.getPortletDisplay().getId(), themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); 
                List<SearchResult> searchResults = SearchResultUtil.getSearchResults(hits,serviceContext.getLocale(), portleturl1);
                
                
                
                for(SearchResult searchResult : searchResults ){
                    Summary summary = searchResult.getSummary();
                    System.out.println("content :"+ summary.getContent());*/
                    
                }

But, this return only the first three occurrences. How to increase searched results snippet content size or length in lifery or is there any other way in liferay to get all occurences?

Olaf Kock
  • 46,930
  • 8
  • 59
  • 90
mariappan k
  • 199
  • 1
  • 12
  • I'm removing the [tag:elasticsearch] tag, as Liferay 6.2 defaults to Lucene and doesn't have any elasticsearch binding - that starts with Liferay 7.0. It's also quite old, you might want to try if the latest version already does exactly what you want out of the box. – Olaf Kock Mar 13 '21 at 12:32

0 Answers0