Hi,
is it possible to index votes collected by the Voting API? I would like to sort results by votes.
Thanks

Comments

cloudbull’s picture

What kinding of indexing you are using ?

If solr, it can be done by programatically adding new field to server.
Then filter by that field.

If mongoDB, you can custom sort by js as well...

Keith

e_log’s picture

Status: Active » Closed (works as designed)

EDIT: if the search is node based then votes can not be indexed because they are stored in the votingapi_vote table and not in the node table....

EDIT 2: It works with custom fields.

Fidelix’s picture

Status: Closed (works as designed) » Active

e_log, what do you mean with "custom fields"?

e_log’s picture

hi Fidelix,
take a look at this link to index custom fields:
http://ygerasimov.com/add-custom-field-search-api-apachesolr-index

For votingapi the callback could look like this:

/**
 * Getter callback for custom_getter_callback_function.
 */
function custom_getter_callback_function($item) {
  $results = db_query('SELECT value FROM {votingapi_cache} WHERE entity_id = :nid AND function = :function', array(':nid' => $item->nid, ':function' => 'votingapi_aggregate_function'));
  $result = $results->fetchField();
  return $result;
}

votingapi_aggregate_function could be a default function like average or sum or a custom function.

Voila, indexing votes.

nick_vh’s picture

Category: Feature request » Support request
Issue summary: View changes
Status: Active » Closed (works as designed)