Find records matching index query - defer to backend.
160267
def find_by_index(self, cls, index_name, value):
        """"""
        return self.backend.find_by_index(cls, index_name, value)
1138451
def exists_query(expression):
    """"""
    def _exists(index, expression=expression):
        """Return store key for documents that satisfy expression."""
        ev = expression() if callable(expression) else expression
        if ev:
            return [
                store_key
                for store_keys
                in index.get_index().values()
                for store_key in store_keys
            ]
        else:
            return index.get_undefined_keys()

    return _exists
1224882
function findRecords(store, fieldName, texts) {
      var records = [];
      texts.forEach(function (text) {
        var index = store.find(fieldName, text);
        if (index === -1) {
          throw new Error('Text: ' + text + ' not found for fieldName: ' + fieldName);
        }
        records.push(index);
      });
      return records;
    }
16288
function (query, indexName) {
        var model = this.collection.get(query, indexName);
        if (model && includes(this.models, model)) return model;
    }
747461
def is_get_query_with_results(results):
        
        return results and EsConst.FOUND in results and results[EsConst.FOUND] and EsConst.FIELDS in results
972146
def _get_query(self, order=None, filters=None):
        
        order = self._get_order(order)
        return self.posts.all().order_by(order)
1017729
def _find_matching_collections_internally(collections, record):
    
    for name, data in iteritems(collections):
        if _build_query(data['query']).match(record):
            yield data['ancestors']
    raise StopIteration
106867
def get_affected_records(spec=None, search_pattern=None):
    
    # spec       pattern    query
    # ---------- ---------- -------
    # None       None       None
    # None       Y          Y
    # X          None       X
    # X          ''         X
    # X          Y          X OR Y

    if spec is None and search_pattern is None:
        raise StopIteration

    queries = []

    if spec is not None:
        queries.append(Q('match', **{'_oai.sets': spec}))

    if search_pattern:
        queries.append(query_string_parser(search_pattern=search_pattern))

    search = OAIServerSearch(
        index=current_app.config['OAISERVER_RECORD_INDEX'],
    ).query(Q('bool', should=queries))

    for result in search.scan():
        yield result.meta.id
134332
def find_every_by_index(options={})
      # Construct the query. First add the type information.
      query =""

      # set default operator
      options[:operator] ||= :or

      # First add the conditions predicates
      conditions = options[:conditions]
      if conditions.is_a?(String)
        query << conditions
      elsif conditions.is_a?(Array) and !conditions.empty?
        nb_conditions = conditions.size - 1
        i = 0
        query << conditions[0].gsub(/\?/) do |c|
          i += 1
          raise ArgumentError, "Missing condition argument" unless i <= nb_conditions
          "#{conditions[i]}"
        end
      elsif conditions.is_a?(Hash) and !conditions.empty?
        conditions.each do |k, v|
          query << "#{k}:#{v} "
        end
      end

      fields =
        if options[:fields]
          options[:fields]
        else
          fields = options[:view] ? index_views_hash[options[:view]] : index_views_hash[:default]
          fields ||= []
        end

      if options[:format] == :ids
        index_adapter.find_ids_by_index(self, query, {  :offset   => options[:offset],
                                                  :order    => options[:order],
                                                  :limit    => options[:limit],
                                                  :fields   => fields,
                                                  :operator => options[:operator],
                                                  :raw_result => options[:raw_result]})
      else
        index_adapter.find_by_index(self, query, {  :offset   => options[:offset],
                                              :order    => options[:order],
                                              :limit    => options[:limit],
                                              :operator => options[:operator],
                                              :raw_result => options[:raw_result]})
      end

    end
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)
710504
def find_all(self, cls):
        """"""
        final_results = []
        for db_result in read_by_indexes(cls.get_table_name(), []):
            obj = cls.from_data(db_result['value'])
            final_results.append(obj)

        return final_results
69909
def find(self, *args, **kwargs):
    " "
    return Query(*args, db=self, schema=self.schema)
90740
def get_records(self, sequence_id, gt=None, gte=None, lt=None, lte=None, limit=None,
                    query_ascending=True, results_ascending=True):
        
293960
def search(session, query):
    
    flat_query = "".join(query.split())

    artists = session.query(Artist).filter(
            or_(Artist.name.ilike(f"%%{query}%%"),
                Artist.name.ilike(f"%%{flat_query}%%"))
               ).all()
    albums = session.query(Album).filter(
            Album.title.ilike(f"%%{query}%%")).all()
    tracks = session.query(Track).filter(
            Track.title.ilike(f"%%{query}%%")).all()

    return dict(artists=artists,
                albums=albums,
                tracks=tracks)
1173593
def query(options, collection_name, num_to_skip, num_to_return,
          query, field_selector, opts, check_keys=False, ctx=None):
    """"""
    if ctx:
        return _query_compressed(options, collection_name, num_to_skip,
                                 num_to_return, query, field_selector,
                                 opts, check_keys, ctx)
    return _query_uncompressed(options, collection_name, num_to_skip,
                               num_to_return, query, field_selector, opts,
                               check_keys)
929190
function (query, indexName) {
        if (!query) return;
        var index = this._indexes[indexName || this.mainIndex];
        return index[query] || index[query[this.mainIndex]] || this._indexes.cid[query] || this._indexes.cid[query.cid];
    }
1031383
def _find(api_method, query, limit, return_handler, first_page_size, **kwargs):
    ''' 
    '''
    num_results = 0

    if "limit" not in query:
        query["limit"] = first_page_size

    while True:
        resp = api_method(query, **kwargs)

        by_parent = resp.get('byParent')
        descriptions = resp.get('describe')
        def format_result(result):
            if return_handler:
                result = dxpy.get_handler(result['id'], project=result.get('project'))
            if by_parent is not None:
                return result, by_parent, descriptions
            else:
                return result

        for i in resp["results"]:
            if num_results == limit:
                return
            num_results += 1
            yield format_result(i)

        # set up next query
        if resp["next"] is not None:
            query["starting"] = resp["next"]
            query["limit"] = min(query["limit"]*2, 1000)
        else:
            return