Adding total views count as a field or filter works fine but it's not available as a sort for some reason like it is on regular content views.

Comments

Status:Active» Postponed

Updates, doesn't work as a filter either, and it appears that view counts are not stored by mongo at all. So it sounds like mongo first needs to make node view counts available before this can be accomplished. Moving this to postponed until #1125886: Support of the core statistics module or something like it lands.

Project:MongoDB» EntityFieldQuery Views Backend
Component:Field storage» Code
Status:Closed (fixed)» Postponed

I ended up just hacking my way around this by 1) adding a regular integer field for view count to the content type, 2) incrementing that field via a custom script that avoids a full drupal bootstrap, and 3) adding the new field to the view as a sort.

Script is below. Put it in the site root as inc.php and use it as an image src like <img src="/inc.php?nid=<nid>" /> whenever you want to increment something. It outputs a 1x1 gif. Thanks to @chx for the bulk of this code.

<?php
if (!is_numeric($_GET['nid'])) {
  header("Status: 404 Not Found");
  exit;
}
$nid = (int) $_GET['nid']; // Not sure why this is needed but it is.
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION);
drupal_load('module', 'mongodb');
mongodb_collection('fields_current', 'node')->update(array('nid' => $nid), array('$inc' => array('field_viewcount.value' => 1)));
header( 'Content-type: image/gif' );
echo chr(71).chr(73).chr(70).chr(56).chr(57).chr(97).
     chr(1).chr(0).chr(1).chr(0).chr(128).chr(0).
     chr(0).chr(0).chr(0).chr(0).chr(0).chr(0).chr(0).
     chr(33).chr(249).chr(4).chr(1).chr(0).chr(0).
     chr(0).chr(0).chr(44).chr(0).chr(0).chr(0).chr(0).
     chr(1).chr(0).chr(1).chr(0).chr(0).chr(2).chr(2).
     chr(68).chr(1).chr(0).chr(59);

Status:Postponed» Closed (fixed)

Project:EntityFieldQuery Views Backend» MongoDB
Component:Code» Field storage
Status:Closed (fixed)» Active

Also please share the Views code. I guess it's a hook_views_data_alter() against efq.

Status:Active» Closed (fixed)

No views code. It's just a regular field added to the content type via the fields GUI, so views can display it and sort by it without any custom code. Like I said, it's a hack, but it worked fine in this situation.

Project:EntityFieldQuery Views Backend» MongoDB
Component:Code» Field storage
Status:Postponed» Closed (fixed)

Oh I missed that! Very tricky. Will commit something to this end.