<?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>How can I get count of Indexer search?</title>
  <link rel="self" href="https://uat.liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=27137979" />
  <subtitle>How can I get count of Indexer search?</subtitle>
  <id>https://uat.liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=27137979</id>
  <updated>2026-10-15T12:00:19Z</updated>
  <dc:date>2026-10-15T12:00:19Z</dc:date>
  <entry>
    <title>RE: How can I get count of Indexer search?</title>
    <link rel="alternate" href="https://uat.liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=119304315" />
    <author>
      <name>Enrique Valdes Lacasa</name>
    </author>
    <id>https://uat.liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=119304315</id>
    <updated>2020-06-03T12:22:56Z</updated>
    <published>2020-06-03T12:22:56Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;In Liferay 7.2, you can do:&lt;br&gt;&lt;pre&gt;&lt;code&gt;searchContext.setStart(page);
searchContext.setEnd(pageSize);&lt;/code&gt;&lt;/pre&gt;And then in the search response:&lt;br&gt;&lt;pre&gt;&lt;code&gt;SearchHits searchHits = searchResponse.getSearchHits();
long totalHits = searchHits.getTotalHits();&lt;/code&gt;&lt;/pre&gt;The totalHits gives you the number of ALL results but the searchHits objects returned are only paginated to the page # and size.&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Enrique Valdes Lacasa</dc:creator>
    <dc:date>2020-06-03T12:22:56Z</dc:date>
  </entry>
  <entry>
    <title>RE: How can I get count of Indexer search?</title>
    <link rel="alternate" href="https://uat.liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=27139791" />
    <author>
      <name>Jim Miller</name>
    </author>
    <id>https://uat.liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=27139791</id>
    <updated>2013-08-08T00:45:53Z</updated>
    <published>2013-08-08T00:45:53Z</published>
    <summary type="html">To answer my own question, when I put SearchContainer.DEFAULT_DELTA in as the delta parameter of the SearchContainer constructor the results total will be wrong. If I put some number like 10 or 15 as the number of rows I want to initially display, the total documents/hits number is correct.</summary>
    <dc:creator>Jim Miller</dc:creator>
    <dc:date>2013-08-08T00:45:53Z</dc:date>
  </entry>
  <entry>
    <title>How can I get count of Indexer search?</title>
    <link rel="alternate" href="https://uat.liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=27137978" />
    <author>
      <name>Jim Miller</name>
    </author>
    <id>https://uat.liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=27137978</id>
    <updated>2013-08-07T22:43:46Z</updated>
    <published>2013-08-07T22:43:46Z</published>
    <summary type="html">I have an Indexer search using a SearchContext to do a custom search of the Document Library.&lt;br /&gt;&lt;br /&gt;      Indexer indexer = IndexerRegistryUtil.getIndexer(DLFileEntry.class);&lt;br /&gt;&lt;br /&gt;      SearchContext searchContext = SearchContextFactory.getInstance(request);&lt;br /&gt;&lt;br /&gt;      searchContext.setEnd(searchContainer.getEnd());&lt;br /&gt;      searchContext.setKeywords(keywords);&lt;br /&gt;      searchContext.setStart(searchContainer.getStart());&lt;br /&gt;&lt;br /&gt;      Hits results = indexer.search(searchContext);&lt;br /&gt;&lt;br /&gt;      int total = results.getLength();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The problem is that results.getLength() or even results.toList().length return a value based on the number of rows displayed in the search container.  For pagination, the search container needs a value for the total number of rows so that it can display something like &amp;#39;Showing 1-10 of 42 results&amp;#39;. Without setting searchContext.setEnd() to some huge number, how do I get a count of all items that match the search?</summary>
    <dc:creator>Jim Miller</dc:creator>
    <dc:date>2013-08-07T22:43:46Z</dc:date>
  </entry>
</feed>
