Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Varun Shahdadpuri
Search Container : Unexpected Behaviour on 1st Page
June 7, 2012 12:46 AM
Answer

Varun Shahdadpuri

Rank: New Member

Posts: 4

Join Date: May 23, 2012

Recent Posts

Hi,

I am using search container to display results from a search.
However, even though the delta value is set to 3, the search-container shows all the records on the first page.

I am using LR 6.0 CE.
Browser - Google Chrome.

Can someone please help?
Attachments: Fullscreen capture 672012 11038 PM.bmp (74.0k)
Amit Doshi
RE: Search Container : Unexpected Behaviour on 1st Page
June 7, 2012 2:26 AM
Answer

Amit Doshi

Rank: Liferay Master

Posts: 547

Join Date: December 29, 2010

Recent Posts

Is it working fine on other browsers?

Sometimes it happens try to do re-indexing.
Varun Shahdadpuri
RE: Search Container : Unexpected Behaviour on 1st Page
June 7, 2012 2:51 AM
Answer

Varun Shahdadpuri

Rank: New Member

Posts: 4

Join Date: May 23, 2012

Recent Posts

Hi,

Yes, it's happening in all the browsers.

How do I reindex DLFiles? I am using the built-in DLIndexer.
Jitendra Rajput
RE: Search Container : Unexpected Behaviour on 1st Page
June 7, 2012 5:07 AM
Answer

Jitendra Rajput

Rank: Liferay Master

Posts: 848

Join Date: January 7, 2011

Recent Posts

If you check in you search container items per page min value is 5 . So i guess you can not set delta less then 5 .
Not sure but can you please try by setting delta > 5 may be try with 6 .
Amit Doshi
RE: Search Container : Unexpected Behaviour on 1st Page
June 7, 2012 4:17 AM
Answer

Amit Doshi

Rank: Liferay Master

Posts: 547

Join Date: December 29, 2010

Recent Posts

Hi Varun,

I think jitendra is right. You can set Delta >5.

And you can do re-indexing from Control panel -> Server Administrator . Click on the Reindex all search indexes Button.

Regards,
Amit Doshi
Vasu Sambangi
RE: Search Container : Unexpected Behaviour on 1st Page
June 7, 2012 5:29 AM
Answer

Vasu Sambangi

Rank: New Member

Posts: 7

Join Date: December 9, 2010

Recent Posts

Hi Varun,

In the Search Container items per page mini value is 5 but you gave below 5, so u have to give above 5 then you can get good result.


Thanks&Regards
Vasu.Sambangi
Varun Shahdadpuri
RE: Search Container : Unexpected Behaviour on 1st Page
June 7, 2012 5:37 AM
Answer

Varun Shahdadpuri

Rank: New Member

Posts: 4

Join Date: May 23, 2012

Recent Posts

Tried with value 6.
Reindex'd all indexes.
Still the same issue.
Hitesh Methani
RE: Search Container : Unexpected Behaviour on 1st Page
June 7, 2012 5:40 AM
Answer

Hitesh Methani

Rank: Regular Member

Posts: 169

Join Date: June 24, 2010

Recent Posts

Hi Varun,

You can define valid delta for search container in portal-ext.properties.
Its default value is
search.container.page.delta.values=5,10,20,30,50,75

Trying changing it according to requirement.

HTH

Thanks and Regards,
Hitesh Methani
manasa chandri
RE: Search Container : Unexpected Behaviour on 1st Page
June 8, 2012 12:43 AM
Answer

manasa chandri

Rank: Regular Member

Posts: 147

Join Date: September 27, 2010

Recent Posts

Hi varun,

check the search container set total list size.

searchContainer.setTotal(assignProjectList.size());

Hope it is helpful..

Regards,
Manasa.
Varun Shahdadpuri
RE: Search Container : Unexpected Behaviour on 1st Page
June 12, 2012 12:22 AM
Answer

Varun Shahdadpuri

Rank: New Member

Posts: 4

Join Date: May 23, 2012

Recent Posts

Guys,

Nothing seems to be working!!
I still get "ALL" the results on the first page no matter what delta value I set... I'm in a dire need of a solution within next two days. emoticon

Attaching my entire search.jsp code.. Hope someone has any idea as to what I'm missing here!

  1
  2
  3<%
  4    String redirect = ParamUtil.getString(request, "redirect");
  5    String keywords0 = ParamUtil.getString(request, "keywords0");
  6    String searchType = ParamUtil.getString(request, "searchType");
  7    System.out.println("KEYWORDS : " + keywords0);
  8    int total = 0;
  9    String description;
 10%>
 11<liferay-portlet:renderURL varImpl="searchURL">
 12    <portlet:param name="jspPage" value="/html/search.jsp" />
 13</liferay-portlet:renderURL>
 14
 15<liferay-ui:header backURL="<%= redirect %>" title="Search Results" />
 16
 17<div class="grid_12 spanning-search marginbottom20"
 18    style="clear: left; margin-bottom: 0">
 19    <form action="<%=searchURL%>" method="get" name="fm0" id="fm0">
 20        <input name="redirect" type="hidden" value="<%= redirect %>" />
 21        <liferay-portlet:renderURLParams varImpl="searchURL" />
 22        <%
 23            PortletURL portletURL = renderResponse.createRenderURL();
 24            portletURL.setParameter("jspPage", "/html/search.jsp");
 25            portletURL.setParameter("redirect", redirect);
 26            portletURL.setParameter("keywords0", keywords0);
 27            portletURL.setParameter("searchType", searchType);
 28            List<String> headerNames = new ArrayList<String>();
 29            headerNames.add("#");
 30            headerNames.add("file");
 31            headerNames.add("description");
 32            SearchContainer<DLFileEntry> searchContainer = new SearchContainer<DLFileEntry>(
 33                    renderRequest,
 34                    null,
 35                    null,
 36                    SearchContainer.DEFAULT_CUR_PARAM,
 37                    5,
 38                    portletURL,
 39                    headerNames,
 40                    LanguageUtil
 41                            .format(pageContext,
 42                                    "no-entries-were-found-that-matched-the-keywords-x",
 43                                    "<strong>" + HtmlUtil.escape(keywords0)
 44                                            + "</strong>"));
 45
 46            DLFileEntry dlFileEntry = null;
 47            long folderId = 0L;
 48            List<DLFolder> childFolders = null;
 49            List<Object> files = null;
 50            String folderName = null;
 51            long[] folderIds = new long[10];
 52            int i = 0;
 53            try {
 54
 55                folderName = searchType;
 56
 57                // get theme-display object to retrieve groupId
 58                themeDisplay = (ThemeDisplay) request
 59                        .getAttribute(WebKeys.THEME_DISPLAY);
 60
 61                System.out.println(themeDisplay.getParentGroupId());
 62
 63                // get folder-id from group-id and using folder-name
 64                try {
 65                    folderId = DLFolderServiceUtil.getFolderId(
 66                            themeDisplay.getParentGroupId(), 0, folderName);
 67                } catch (Exception e) {
 68                    if (e instanceof SystemException
 69                            || e instanceof PortalException) {
 70                        folderId = (-1);
 71                    } else
 72                        throw e;
 73                }
 74
 75                System.out.println(folderId);
 76
 77                folderIds[i++] = folderId;
 78                // get all the child folders
 79                childFolders = DLFolderServiceUtil.getFolders(
 80                        themeDisplay.getParentGroupId(), folderId);
 81
 82                // get all folder-ids of child-folder
 83                if (!childFolders.isEmpty()) {
 84                    for (DLFolder dlFolder : childFolders) {
 85                        System.out.println(dlFolder.getFolderId());
 86                        folderIds[i++] = dlFolder.getFolderId();
 87                    }
 88                }
 89
 90                Indexer indexer = IndexerRegistryUtil
 91                        .getIndexer(DLFileEntry.class);
 92                SearchContext searchContext = SearchContextFactory
 93                        .getInstance(request);
 94                searchContext.setEnd(searchContainer.getEnd());
 95                if (!keywords0.trim().equals("")) {
 96                    searchContext.setKeywords(keywords0);
 97                }
 98                searchContext.setStart(searchContainer.getStart());
 99
100                //Add folder-ids and group-ids
101                searchContext.setCompanyId(themeDisplay.getCompanyId());
102                searchContext.setFolderIds(folderIds);
103                searchContext.setEnd(100);
104                long[] groupIds = { themeDisplay.getParentGroupId() };
105                searchContext.setGroupIds(groupIds);
106                Hits results = indexer.search(searchContext);
107                total = results.getLength();
108                searchContainer.setTotal(total);
109                List<ResultRow> resultRows = searchContainer.getResultRows();
110                for (i = 0; i < results.getDocs().length; i++) {
111                    Document doc = results.doc(i);
112                    ResultRow row = new ResultRow(doc, i, i);
113                    // Position
114                    row.addText(searchContainer.getStart() + i + 1
115                            + StringPool.PERIOD);
116                    // Slogan
117                    long fileId = GetterUtil.getLong(doc
118                            .get(Field.ENTRY_CLASS_PK));
119                    dlFileEntry = DLFileEntryLocalServiceUtil
120                            .getDLFileEntry(fileId);
121                    String fileDownloadURL = "/documents/"
122                            + themeDisplay.getParentGroupId() + "/"
123                            + dlFileEntry.getUuid();
124                    row.addText(dlFileEntry.getTitle(), fileDownloadURL);
125                    // description
126
127                    if (dlFileEntry.getDescription() != null
128                            && !dlFileEntry.getDescription().trim().equals("")) {
129                        description = dlFileEntry.getDescription();
130                    } else
131                        description = StringUtil.shorten(
132                                doc.get(Field.CONTENT), 200);
133
134                    row.addText(description);
135                    // Add result row
136                    resultRows.add(row);
137                }
138            } catch (Exception e) {
139                e.printStackTrace();
140            }
141        %>
142
143        <input type="text" name="keywords0" size="30" title="search-entries"
144            value="<%=keywords0%>" onfocus="clearField(this)"
145            onblur="fillField(this)" class="search-short"> <input
146            type="hidden" name="searchType" value="Code"> <a
147            href="javascript:submitForm()" class="blue-button">Search</a>
148    </form>
149</div>
150<br />
151<br />
152<%
153    if (total <= 0) {
154%>
155<br />
156<br />
157<%
158    }
159%>
160<liferay-ui:search-iterator searchContainer="<%= searchContainer %>" paginate="true"/>
Robert Rayas
RE: Search Container : Unexpected Behaviour on 1st Page
May 13, 2015 10:20 AM
Answer

Robert Rayas

Rank: New Member

Posts: 12

Join Date: November 28, 2014

Recent Posts

Hi,
When you define search container, total is the size of your fill results list and results is the sublist that you want shown on that page.
I used jstl to define search container so I have
<%
renderRequest.setAttribute("count", CommunityUsersList.size());
List<User> CommunityUsersList2=CommunityUsersList.subList(start,end);
renderRequest.setAttribute("CommunityUsersList", CommunityUsersList2);
%>
<liferay-ui:search-container-results
results="${ CommunityUsersList }"
total="${count}"
/>