Persistent dictionary usage to retrieve the search indexes
493073
def get_data(url, gallery_dir):
    """"""

    # shelve keys need to be str in python 2
    if sys.version_info[0] == 2 and isinstance(url, unicode):
        url = url.encode('utf-8')

    cached_file = os.path.join(gallery_dir, 'searchindex')
    search_index = shelve.open(cached_file)
    if url in search_index:
        data = search_index[url]
    else:
        data = _get_data(url)
        search_index[url] = data
    search_index.close()

    return data
1205053
def getDictionary(self):
		
		if os.path.exists(self.jsonFile):
			return json.loads(Utility.readFile(self.jsonFile))
		else:
			return {}
133540
def keys(self, index=None):
        
        if index is not None and index not in self._indexes:
            raise ValueError('Index {} does not exist'.format(index))

        db = self._indexes[index][0] if index else self._main_db
        with self._lmdb.begin(db=db) as txn:
            return [
                key.decode()
                for key in txn.cursor().iternext(keys=True, values=False)
            ]
517671
def queryables(self):
        

        # compute the values_axes queryables
        return dict(
            [(a.cname, a) for a in self.index_axes] +
            [(self.storage_obj_type._AXIS_NAMES[axis], None)
             for axis, values in self.non_index_axes] +
            [(v.cname, v) for v in self.values_axes
             if v.name in set(self.data_columns)]
        )
669907
def indexes(dic, keys=None):
    
    keys = [] if keys is None else keys

    assert hasattr(dic, 'keys')
    new = dic.copy()
    old_key = None
    for key in keys:
        if not hasattr(new, 'keys'):
            raise KeyError('No indexes after: {}'.format(old_key))
        old_key = key
        new = new[key]
    return new
298254
def index(cls):
        
        res = requests.get(cls.URL, headers=HEADERS, verify=False)
        res.raise_for_status()
        return res.json()
20016
def refresh(self):
        
        self.client.indices.refresh(index=self.model.search_objects.mapping.index)
67488
def _get_indexing_dispatch_code(key):
    """"""
    if isinstance(key, (NDArray, np.ndarray)):
        return _NDARRAY_ADVANCED_INDEXING
    elif isinstance(key, list):
        # TODO(junwu): Add support for nested lists besides integer list
        for i in key:
            if not isinstance(i, integer_types):
                raise TypeError('Indexing NDArray only supports a list of integers as index'
                                ' when key is of list type, received element=%s of type=%s'
                                % (str(i), str(type(i))))
        return _NDARRAY_ADVANCED_INDEXING
    elif isinstance(key, (integer_types, py_slice)):
        return _NDARRAY_BASIC_INDEXING
    elif isinstance(key, tuple):
        for idx in key:
            if isinstance(idx, (NDArray, np.ndarray, list, tuple)):
                return _NDARRAY_ADVANCED_INDEXING
            elif not isinstance(idx, (py_slice, integer_types)):
                raise ValueError("NDArray does not support slicing with key %s of type %s."
                                 % (str(idx), str(type(idx))))
        return _NDARRAY_BASIC_INDEXING
    else:
        return _NDARRAY_UNSUPPORTED_INDEXING
221876
def get_dicts(self):
        
        if self.word_dict is None:
            self.word_dict, self.char_dict, self.max_word_len = self.dict_generator(return_dict=True)
        return self.word_dict, self.char_dict
415676
def get_filtered_keys(self, suffix, *args, **kwargs):
        

        args = self.prepare_args(args, transform=False)

        for index in self._indexes:
            if index.can_handle_suffix(suffix):
                return index.get_filtered_keys(suffix, *args, **kwargs)
919403
private long[] indexes(ByteBuffer key)
    {
        // we use the same array both for storing the hash result, and for storing the indexes we return,
        // so that we do not need to allocate two arrays.
        long[] indexes = reusableIndexes.get();
        hash(key, key.position(), key.remaining(), 0L, indexes);
        setIndexes(indexes[0], indexes[1], hashCount, bitset.capacity(), indexes);
        return indexes;
    }
8001
def to_dict(self):
        """"""
        out = {}

        fields = self.__class__.search_objects.mapping.properties.properties

        for key in fields:
            # TODO: What if we've mapped the property to a different name? Will we allow that?

            attribute = getattr(self, key)

            field = fields[key]

            # I believe this should take the highest priority.
            if hasattr(field, "to_es"):
                out[key] = field.to_es(attribute)

            # First we check it this is a manager, in which case we have many related objects
            elif isinstance(attribute, models.Manager):
                if issubclass(attribute.model, Indexable):
                    # TODO: We want this to have some awareness of the relevant field.
                    out[key] = [obj.to_dict() for obj in attribute.all()]
                else:
                    out[key] = list(attribute.values_list("pk", flat=True))

            elif callable(attribute):
                out[key] = attribute()

            elif isinstance(attribute, Indexable):
                out[key] = attribute.to_dict()
            else:
                out[key] = attribute

            if out[key] is None:
                del out[key]
        return out
533402
def dict(self):
    ''''''
    d = dict()
    d['key'] = str(self.key)

    if self.limit is not None:
      d['limit'] = self.limit
    if self.offset > 0:
      d['offset'] = self.offset
    if self.offset_key:
      d['offset_key'] = str(self.offset_key)
    if len(self.filters) > 0:
      d['filter'] = [[f.field, f.op, f.value] for f in self.filters]
    if len(self.orders) > 0:
      d['order'] = [str(o) for o in self.orders]

    return d
1037345
def search_document_cache_key(self):
        """"""
        return "elasticsearch_django:{}.{}.{}".format(
            self._meta.app_label, self._meta.model_name, self.pk
        )
733251
def get_position_searchable(self):
        
        ids = gkr.list_item_ids_sync(self.keyring)
        position_searchable = {}
        for i in ids:
            item_attrs = gkr.item_get_attributes_sync(self.keyring, i)
            position_searchable[i] = item_attrs['searchable'] 
        return position_searchable
1184053
def list_search_indexes(self):
        
        if not self.yz_wm_index:
            raise NotImplementedError("Search 2.0 administration is not "
                                      "supported for this version")

        url = self.search_index_path()

        # Run the request...
        status, headers, body = self._request('GET', url)

        if status == 200:
            json_data = json.loads(bytes_to_str(body))
            # Return a list of dictionaries
            return json_data
        else:
            raise RiakError('Error getting Search 2.0 index.')
1153597
def _to_dict(self):
        """"""
        _dict = {}
        if hasattr(self,
                   'matching_results') and self.matching_results is not None:
            _dict['matching_results'] = self.matching_results
        if hasattr(self, 'hits') and self.hits is not None:
            _dict['hits'] = [x._to_dict() for x in self.hits]
        return _dict