<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>searchContainer doesn't change after removing an object from User List L6.2</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=111596662" />
  <subtitle>searchContainer doesn't change after removing an object from User List L6.2</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=111596662</id>
  <updated>2026-04-04T02:24:37Z</updated>
  <dc:date>2026-04-04T02:24:37Z</dc:date>
  <entry>
    <title>RE: searchContainer doesn't change after removing an object from User List</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111834348" />
    <author>
      <name>JAOUAD MOUAOU</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111834348</id>
    <updated>2018-12-18T15:47:10Z</updated>
    <published>2018-12-18T15:47:10Z</published>
    <summary type="html">&lt;p&gt;Thanks, I've used your first approach, but on usersRoles and it seems
  to work.&lt;/p&gt;
&lt;pre&gt;
if (roleid .equals(9898)) {
    userParams.put(&amp;quot;usersRoles&amp;quot;, Long.parseLong(roleid));
} &lt;/pre&gt;</summary>
    <dc:creator>JAOUAD MOUAOU</dc:creator>
    <dc:date>2018-12-18T15:47:10Z</dc:date>
  </entry>
  <entry>
    <title>RE: searchContainer doesn't change after removing an object from User List</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111722631" />
    <author>
      <name>Amos Fong</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111722631</id>
    <updated>2018-12-03T22:02:25Z</updated>
    <published>2018-12-03T22:02:25Z</published>
    <summary type="html">If you're doing a search with -1, -1 as start, end, it's going to return
all users which of course be slow if you have over 100,000. So you've
got to find a more efficient way to do this. I would suggest, (assuming
the comparison can be done on user update) to add a new field in the
search index on the user document probably with a &lt;a
  href="https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/model-listeners"&gt;mode listener&lt;/a&gt;
. Then add it to search via a &lt;a
  href="https://dev.liferay.com/develop/reference/-/knowledge_base/7-0/indexer-post-processor"&gt;Indexer
  Post Processor&lt;/a&gt;
.</summary>
    <dc:creator>Amos Fong</dc:creator>
    <dc:date>2018-12-03T22:02:25Z</dc:date>
  </entry>
  <entry>
    <title>RE: searchContainer doesn't change after removing an object from User List</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111721963" />
    <author>
      <name>JAOUAD MOUAOU</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111721963</id>
    <updated>2018-12-03T21:41:18Z</updated>
    <published>2018-12-03T21:41:18Z</published>
    <summary type="html">&lt;p&gt;Any help guys.&lt;/p&gt;</summary>
    <dc:creator>JAOUAD MOUAOU</dc:creator>
    <dc:date>2018-12-03T21:41:18Z</dc:date>
  </entry>
  <entry>
    <title>RE: searchContainer doesn't change after removing an object from User List</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111627784" />
    <author>
      <name>JAOUAD MOUAOU</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111627784</id>
    <updated>2018-11-21T15:02:59Z</updated>
    <published>2018-11-21T15:02:59Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;p&gt;Thanks for your reply, Amos. I've tried your solution and I can
  filter based on some value, but still doesn't&amp;nbsp;get me what I want. The
  way the new search directory work is it runs the search first on the
  Liferay&amp;nbsp;database and after that, I make another connection to an
  external database that uses screenName as the primary&amp;nbsp;key for users.
  After that I do a comparison between Liferay&amp;nbsp;database and another
  external database and bring the matching rows and display them on the
  search container.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If I do something like this it works just fine on development env
  which has just a few users 100 maybe, but when I deploy the hook to
  pre-prod which has over 100,000 users the connection times out or it
  takes longer to respond if there are just few return values.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;pre&gt;
&lt;code&gt;results = UserLocalServiceUtil.search(company.getCompanyId(), searchTerms.getKeywords(), searchTerms.getStatus(), userParams, &amp;lt;span style="color: rgb(255,0,0);"&amp;gt;-1&amp;lt;/span&amp;gt;, &amp;lt;span style="color: rgb(255,0,0);"&amp;gt;-1&amp;lt;/span&amp;gt;, userSearchContainer.getOrderByComparator());&lt;/code&gt;&lt;/pre&gt;&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>JAOUAD MOUAOU</dc:creator>
    <dc:date>2018-11-21T15:02:59Z</dc:date>
  </entry>
  <entry>
    <title>RE: searchContainer doesn't change after removing an object from User List</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111615737" />
    <author>
      <name>Amos Fong</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111615737</id>
    <updated>2018-11-20T20:55:03Z</updated>
    <published>2018-11-20T20:55:03Z</published>
    <summary type="html">&lt;p&gt;That's because you set the total to the current page's results. So it
  thinks there's no more results and doesn't render pagination.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;This probably isn't the best way to filter because some pages may
  have differing amount of results depending if there's a user to filter
  or not. I think you could do something like this to add to the query:&lt;/p&gt;
&lt;pre&gt;
userParams.put(&amp;quot;test&amp;quot;, new CustomSQLParam(&amp;quot;WHERE User_.screeName != 'sadf'&amp;quot;, StringPool.BLANK));&lt;/pre&gt;</summary>
    <dc:creator>Amos Fong</dc:creator>
    <dc:date>2018-11-20T20:55:03Z</dc:date>
  </entry>
  <entry>
    <title>searchContainer doesn't change after removing an object from User List L6.2</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111596661" />
    <author>
      <name>JAOUAD MOUAOU</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=111596661</id>
    <updated>2018-11-19T20:42:56Z</updated>
    <published>2018-11-19T20:42:56Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;p&gt;I'm creating a hook for Site&amp;nbsp;Members&amp;nbsp;Directory. My requirement&amp;nbsp;is to
  filter the search container based on a&amp;nbsp;String value. I was able to
  remove the objects that I don't want and return new&amp;nbsp;User List with a
  new size. But the problem is that the results show&amp;nbsp;just the first page
  of results. For example, let's say I run a search and return 20
  objects and after the filter, I return 15 objects. In my view&amp;nbsp;page, it
  will only display the 1st page and no pagination. I have set delta to
  5 so it should show 3 pages but it shows&amp;nbsp;only one.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;&amp;amp;lt;%
userSearchContainer.setDelta(5);&lt;/code&gt;

&lt;code&gt;if (searchTerms.isAdvancedSearch()) {
    total = UserLocalServiceUtil.searchCount(company.getCompanyId(), searchTerms.getFirstName(), searchTerms.getMiddleName(), searchTerms.getLastName(), searchTerms.getScreenName(), searchTerms.getEmailAddress(), searchTerms.getStatus(), userParams, searchTerms.isAndOperator());&lt;/code&gt;

&lt;code&gt;    userSearchContainer.setTotal(total);&lt;/code&gt;

&lt;code&gt;    results = UserLocalServiceUtil.search(company.getCompanyId(), searchTerms.getFirstName(), searchTerms.getMiddleName(), searchTerms.getLastName(), searchTerms.getScreenName(), searchTerms.getEmailAddress(), searchTerms.getStatus(), userParams, searchTerms.isAndOperator(), userSearchContainer.getStart(), userSearchContainer.getEnd(), userSearchContainer.getOrderByComparator());&lt;/code&gt;

&lt;code&gt;} else if (Validator.isNotNull(searchTerms.getKeywords())){
    total = UserLocalServiceUtil.searchCount(company.getCompanyId(), searchTerms.getKeywords(), searchTerms.getStatus(), userParams);&lt;/code&gt;

&lt;code&gt;    userSearchContainer.setTotal(total);
   
    results = UserLocalServiceUtil.search(company.getCompanyId(), searchTerms.getKeywords(), searchTerms.getStatus(), userParams, userSearchContainer.getStart(), userSearchContainer.getEnd(), userSearchContainer.getOrderByComparator());
}
    //filter search results
    if(results != null){
     Iterator&amp;amp;lt;User&amp;amp;gt; iterator = results.iterator();
        while(iterator.hasNext()){
            User res = iterator.next(); %&amp;amp;gt;
            String TestValue = "test123";
            &amp;amp;lt;%
            if(!res.getScreenName().equals(TestValue)){
                iterator.remove();
        }
      }
    }&lt;/code&gt;



&lt;code&gt;System.out.println("New List Total " + results.size());    &lt;/code&gt;

&lt;code&gt;//set new list size
userSearchContainer.setTotal(results.size());&lt;/code&gt;

&lt;code&gt;//set new list results
userSearchContainer.setResults(results);&lt;/code&gt;

&lt;code&gt;%&amp;amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>JAOUAD MOUAOU</dc:creator>
    <dc:date>2018-11-19T20:42:56Z</dc:date>
  </entry>
</feed>
