Entity API = 7.x-1.0-beta9
Search API solr = 7.x-1.0-beta3

I have been playing around views Views integration and the Search API and I am finding that the node count always maxes out at 10, regardless of the type of view I am creating.

Example: I created a view based on a taxonomy entity index. It is correctly pulling taxonomy terms into a view. If there are less than 10 nodes associated with that term, the node count is correct. If there are more than 10, node count always shows 10.

Note: I have also created facets, and they display the correct node count.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

drunken monkey’s picture

Project: Search API » Entity API
Version: 7.x-1.0-beta10 » 7.x-1.0-beta9
Component: Views integration » Core integration

Weird, but seems to be an Entity API problem. At least I couldn't imagine what could go wrong on the Search API end there.

fago’s picture

Title: Node count maxes out at 10 in Views? » taxonomy term node count property maxes out at 10
ethnovode’s picture

Hello,
Is there a solution for this ? I'd like to display the top categories inside a view using search api solr.
Thanks.

ethnovode’s picture

Version: 7.x-1.0-beta9 » 7.x-1.0-rc3
colle901’s picture

I think it can be fixed by changing the call on line 266 in entity/modules/callbacks.inc:

function entity_metadata_taxonomy_term_get_properties($term, array $options, $name) {
  switch ($name) {
    case 'node_count':
      return count(taxonomy_select_nodes($term->tid));

Change to:

function entity_metadata_taxonomy_term_get_properties($term, array $options, $name) {
  switch ($name) {
    case 'node_count':
      return count(taxonomy_select_nodes($term->tid, FALSE, FALSE, array()));

The second parameter needs to be FALSE, otherwise paging kicks in (hence the result of 10). The fourth parameter can be set to an empty array since sorting is not necessary for the count.

afranioce’s picture

comment #5 resolve this problem

rafenden’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
642 bytes

Here is the patch.

Chris Matthews’s picture

Version: 7.x-1.0-rc3 » 7.x-1.x-dev

The 2 year old patch in #7 to callbacks.inc applied cleanly to the latest entity 7.x-1.x-dev and (if still relevant) needs review.