Index the database.
433755
def index(ctx, view):
    """"""
    adapter = ctx.obj['adapter']
    if view:
        click.echo(adapter.indexes())
        return
    adapter.ensure_indexes()
286900
def getIndexes(self) :
        """"""
        url = "%s/index" % self.database.URL
        r = self.connection.session.get(url, params = {"collection": self.name})
        data = r.json()
        for ind in data["indexes"] :
            self.indexes[ind["type"]][ind["id"]] = Index(collection = self, infos = ind)

        return self.indexes
466037
def write_index(self):
        """"""
        self.fileobj.seek(self.last_offset)
        index = index_header.build(dict(entries=self.entries))
        self.fileobj.write(index)
        self.filesize = self.fileobj.tell()
264322
def _add_indices(self):
        """"""
        self._logger.info('Adding database indices')
        self._conn.execute(constants.CREATE_INDEX_TEXTNGRAM_SQL)
        self._logger.info('Indices added')
1020673
def _get_indexes(self, schema, **kwargs):
        """"""
        ret = {}
        query_str = []
        query_str.append('SELECT')
        query_str.append('  tbl.relname AS table_name, i.relname AS index_name, a.attname AS field_name,')
        query_str.append('  ix.indkey AS index_order, a.attnum AS field_num')
        query_str.append('FROM')
        query_str.append('  pg_class tbl, pg_class i, pg_index ix, pg_attribute a')
        query_str.append('WHERE')
        query_str.append('  tbl.oid = ix.indrelid AND i.oid = ix.indexrelid AND a.attrelid = tbl.oid')
        query_str.append('  AND a.attnum = ANY(ix.indkey) AND tbl.relkind = %s AND tbl.relname = %s')
        query_str.append('ORDER BY')
        query_str.append('  tbl.relname, i.relname')
        query_str = os.linesep.join(query_str)

        indexes = self.query(query_str, 'r', str(schema), **kwargs)

        # massage the data into more readable {index_name: fields} format
        for idict in indexes:
            if idict['index_name'] not in ret:
                ret[idict['index_name']] = list(map(int, idict['index_order'].split(' ')))

            i = ret[idict['index_name']].index(idict['field_num'])
            ret[idict['index_name']][i] = idict['field_name']

        return ret
273548
private function writeIndexes()
    {
        //Begin database batch
        $this->beginBatch();

        //Index all node entities
        foreach ($this->nodeEntities as $entity)
        {
            $this->index($entity);
        }

        //Index all relation entities
        foreach ($this->relationEntities as $entity)
        {
            $this->index($entity);
        }

        //Write all repository indexes
        foreach ($this->repositories as $repository)
        {
            $repository->writeIndex();
        }

        //Commit batch to the database
        $this->commitBatch();
    }
375726
public function index()
    {
        $groups = $this->Filter->filter($this->Groups->find('all'));
        $this->set([
            'groups' => $this->Filter->paginate($groups)
        ]);
    }
290936
def index(self, refresh=False):
        """"""
        es = connections.get_connection("default")
        index = self.__class__.search_objects.mapping.index
        doc_type = self.__class__.search_objects.mapping.doc_type
        es.index(index, doc_type,
                 id=self.pk,
                 body=self.to_dict(),
                 refresh=refresh)
535150
def index_all(self):
        
        self.logger.debug('Start indexing all records under: %s',
                          self.record_path)
        with self.db.connection():
            for json_path in sorted(self.find_record_files()):
                self.index_record(json_path)
313712
function index(req, res, next) {
  var nextPage
    , prevPage
    , page
    , links = {}
    , link = req.url + '?page=';

  db.users.all({page: req.query.page, limit: req.query.limit}, function(err, result) {
    if(err) { return next(err); }

    page = result.page;
    nextPage = result.count - (result.limit + result.offset) > 0;
    prevPage = page > 1;

    if(nextPage) links.next = link + (page + 1);
    if(prevPage) links.prev = link + (page - 1);
    if(Object.keys(links).length) res.links(links);

    res.json({
      links: links,
      page: page,
      count: result.count,
      users: result.rows,
      next: nextPage,
      prev: prevPage
    });

  });
}
1133614
def _write_indexlist(self, name):
        """"""
        d = [self._site.timeline.index(p) for p in getattr(self._site, name)]
        self.db.delete('site:{0}'.format(name))
        if d:
            self.db.rpush('site:{0}'.format(name), *d)
1092750
def simple_ensure_index(request, database_name, collection_name):
    """"""
    name = ""

    if request.method == 'POST':
        form = EnsureIndexForm(request.POST)

        if form.is_valid():
            result = form.save(database_name, collection_name)
            messages.success(request,
                             _("Index for %s created successfully" % result))
            return HttpResponseRedirect(reverse('djmongo_show_dbs'))
        else:
            # The form is invalid
            messages.error(
                request, _("Please correct the errors in the form."))
            return render(request,
                          'djmongo/console/generic/bootstrapform.html',
                          {'form': form, 'name': name})

    else:
        # this is a GET
        context = {'name': name,
                   'form': EnsureIndexForm(
                       initial={"database_name": database_name,
                                "collection_name": collection_name})
                   }
        return render(request, 'djmongo/console/generic/bootstrapform.html',
                      context)
7891
private function write_index()
    {
        if (!$this->db || $this->type == 'db') {
            return;
        }

        $this->load_index();

        // Make sure index contains new keys
        foreach ($this->cache as $key => $value) {
            if ($value !== null && !in_array($key, $this->index)) {
                $this->index[] = $key;
            }
        }

        // new keys added using self::write()
        foreach ($this->cache_sums as $key => $value) {
            if ($value === true && !in_array($key, $this->index)) {
                $this->index[] = $key;
            }
        }

        $data = serialize($this->index);
        $this->add_record($this->ikey(), $data);
    }
1236797
def create_index(self, collection, index_name, **kwargs):
        """"""
        try:
            self.connection[collection].create_index(index_name, **kwargs)
        except Exception as exc:
            LOG.warn("Error tuning mongodb database: %s", exc)
1177460
public function index()
    {
        $this->paginate = [
            'order' => ['unique_string'=>'DESC']
        ];
        
        $this->set('permission', $this->paginate($this->Permission));
        $this->set('_serialize', ['permission']);
    }
595181
def _put_into_indexes(self, obj):
        
        no_of_used_indexes = 0
        for field_name, db_index in list(self._get_db_fields(obj)):
            attr_value = getattr(obj, field_name)

            if attr_value is None:  # index only by set attributes
                continue

            container = db_index.get(attr_value, None)
            if container is None:
                container = OOTreeSet()
                db_index[attr_value] = container

            container.insert(obj)

            no_of_used_indexes += 1

        # make sure that atleast one `attr_value` was used
        if no_of_used_indexes <= 0:
            raise UnindexableObject(
                "You have to use atleast one of the identificators!"
            )
101256
private function load_index()
    {
        if (!$this->db || $this->type == 'db') {
            return;
        }

        if ($this->index !== null) {
            return;
        }

        $index_key = $this->ikey();

        if ($this->type == 'memcache') {
            $data = $this->db->get($index_key);
        }
        else if ($this->type == 'apc') {
            $data = apc_fetch($index_key);
        }

        if ($this->debug) {
            $this->debug('get', $index_key, $data);
        }

        $this->index = $data ? unserialize($data) : array();
    }