function _apachesolr_index_get_next_set_query in Apache Solr Search 7
Same name and namespace in other branches
- 8 apachesolr.index.inc \_apachesolr_index_get_next_set_query()
- 6.3 apachesolr.index.inc \_apachesolr_index_get_next_set_query()
Internal function that identifies entities that are still due to be indexed.
Parameters
string $env_id Environment ID:
string $entity_type:
Return value
2 calls to _apachesolr_index_get_next_set_query()
- apachesolr_index_get_entities_to_index in ./
apachesolr.index.inc - Returns an array of rows from a query based on an indexing environment. @todo Remove the read only because it is not environment specific
- apachesolr_index_status in ./
apachesolr.index.inc - Returns the total number of documents that are able to be indexed and the number of documents left to be indexed.
File
- ./
apachesolr.index.inc, line 610 - Functions related to Apache Solr indexing operations.
Code
function _apachesolr_index_get_next_set_query($env_id, $entity_type) {
$table = apachesolr_get_indexer_table($entity_type);
// Get $last_entity_id and $last_changed.
$last_index_position = apachesolr_get_last_index_position($env_id, $entity_type);
$bundles = apachesolr_get_index_bundles($env_id, $entity_type);
$last_entity_id = $last_index_position['last_entity_id'];
$last_changed = $last_index_position['last_changed'];
// Find the next batch of entities to index for this entity type. Note that
// for ordering we're grabbing the oldest first and then ordering by ID so
// that we get a definitive order.
// Also note that we fetch ALL fields from the indexer table
$query = db_select($table, 'aie')
->fields('aie')
->condition('aie.bundle', $bundles)
->condition('aie.status', 1)
->condition(db_or()
->condition('aie.changed', $last_changed, '>')
->condition(db_and()
->condition('aie.changed', $last_changed, '=')
->condition('aie.entity_id', $last_entity_id, '>')))
->orderBy('aie.changed', 'ASC')
->orderBy('aie.entity_id', 'ASC')
->addTag('apachesolr_index_' . $entity_type);
if ($table == 'apachesolr_index_entities') {
// Other, entity-specific tables don't need this condition.
$query
->condition('aie.entity_type', $entity_type);
}
return $query;
}