Search for artists, albums, tracks, users or all kinds of objects.
540424
def search_json(query,types=nil,never_or=nil,extras=nil,start=nil,count=nil)
      method = 'search'
      type = TODO
      if not types
        types = 'Artist,Album,Track,Playlist,User'
      end
      args = {:query=>query}
      args[:types] = types if types
      args[:never_or] = never_or if never_or
      args[:extras] = extras if extras
      args[:start] = start if start
      args[:count] = count if count
      
      json = call method,args
      if Rdio::log_json
        Rdio::log json
      end
      return unwrap_json json
    end
338053
def search(self, event):
        """"""

        try:
            data, schema, user, client = self._get_args(event)
        except AttributeError:
            return

        # object_filter['$text'] = {'$search': str(data['search'])}
        if data.get('fulltext', False) is True:
            object_filter = {
                'name': {
                    '$regex': str(data['search']),
                    '$options': '$i'
                }
            }
        else:
            if isinstance(data['search'], dict):
                object_filter = data['search']
            else:
                object_filter = {}

        if 'fields' in data:
            fields = data['fields']
        else:
            fields = []

        skip = data.get('skip', 0)
        limit = data.get('limit', 0)
        sort = data.get('sort', None)
        # page = data.get('page', 0)
        # count = data.get('count', 0)
        #
        # if page > 0 and count > 0:
        #     skip = page * count
        #     limit = count

        if 'subscribe' in data:
            self.log('Subscription:', data['subscribe'], lvl=verbose)
            do_subscribe = data['subscribe'] is True
        else:
            do_subscribe = False

        object_list = []

        size = objectmodels[schema].count(object_filter)

        if size > WARNSIZE and (limit > 0 and limit > WARNSIZE):
            self.log("Getting a very long (", size, ") list of items for ", schema,
                     lvl=warn)

        opts = schemastore[schema].get('options', {})
        hidden = opts.get('hidden', [])

        self.log("object_filter: ", object_filter, ' Schema: ', schema,
                 "Fields: ", fields,
                 lvl=verbose)

        options = {}
        if skip > 0:
            options['skip'] = skip
        if limit > 0:
            options['limit'] = limit
        if sort is not None:
            options['sort'] = []
            for item in sort:
                key = item[0]
                direction = item[1]
                direction = ASCENDING if direction == 'asc' else DESCENDING
                options['sort'].append([key, direction])

        cursor = objectmodels[schema].find(object_filter, **options)

        for item in cursor:
            if not self._check_permissions(user, 'list', item):
                continue
            self.log("Search found item: ", item, lvl=verbose)

            try:
                list_item = {'uuid': item.uuid}
                if fields in ('*', ['*']):
                    item_fields = item.serializablefields()
                    for field in hidden:
                        item_fields.pop(field, None)
                    object_list.append(item_fields)
                else:
                    if 'name' in item._fields:
                        list_item['name'] = item.name

                    for field in fields:
                        if field in item._fields and field not in hidden:
                            list_item[field] = item._fields[field]
                        else:
                            list_item[field] = None

                    object_list.append(list_item)

                if do_subscribe:
                    self._add_subscription(item.uuid, event)
            except Exception as e:
                self.log("Faulty object or field: ", e, type(e),
                         item._fields, fields, lvl=error, exc=True)
        # self.log("Generated object search list: ", object_list)

        result = {
            'component': 'hfos.events.objectmanager',
            'action': 'search',
            'data': {
                'schema': schema,
                'list': object_list,
                'size': size
            }
        }

        self._respond(None, result, event)
1286722
async def search(self, album, artist):
    
    self.logger.debug("Searching with source '%s'..." % (self.__class__.__name__))
    album = self.processAlbumString(album)
    artist = self.processArtistString(artist)
    url_data = self.getSearchUrl(album, artist)
    if isinstance(url_data, tuple):
      url, post_data = url_data
    else:
      url = url_data
      post_data = None
    try:
      store_in_cache_callback, api_data = await self.fetchResults(url, post_data)
      results = await self.parseResults(api_data)
    except Exception as e:
      # raise
      self.logger.warning("Search with source '%s' failed: %s %s" % (self.__class__.__name__,
                                                                     e.__class__.__qualname__,
                                                                     e))
      return ()
    else:
      if results:
        # only store in cache if parsing succeeds and we have results
        await store_in_cache_callback()

    # get metadata
    futures = []
    for result in filter(operator.methodcaller("needMetadataUpdate"), results):
      coroutine = result.updateImageMetadata()
      future = asyncio.ensure_future(coroutine)
      futures.append(future)
    if futures:
      await asyncio.wait(futures)
    for future in futures:
      future.result()  # raise pending exception if any

    # filter
    results_excluded_count = 0
    reference_only_count = 0
    results_kept = []
    for result in results:
      if ((result.size[0] + (self.size_tolerance_prct * self.target_size / 100) < self.target_size) or  # skip too small images
              (result.size[1] + (self.size_tolerance_prct * self.target_size / 100) < self.target_size) or
              (result.format is None) or  # unknown format
              result.needMetadataUpdate()):  # if still true, it means we failed to grab metadata, so exclude it
        if result.source_quality is CoverSourceQuality.REFERENCE:
          # we keep this result just for the reference, it will be excluded from the results
          result.is_only_reference = True
          results_kept.append(result)
          reference_only_count += 1
        else:
          results_excluded_count += 1
      else:
        results_kept.append(result)
    result_kept_count = len(results_kept) - reference_only_count

    # log
    self.logger.info("Got %u relevant (%u excluded) results from source '%s'" % (result_kept_count,
                                                                                 results_excluded_count + reference_only_count,
                                                                                 self.__class__.__name__))
    for result in itertools.filterfalse(operator.attrgetter("is_only_reference"), results_kept):
      self.logger.debug("%s %s%s %4dx%4d %s%s" % (result.__class__.__name__,
                                                  ("(%02d) " % (result.rank)) if result.rank is not None else "",
                                                  result.format.name,
                                                  result.size[0],
                                                  result.size[1],
                                                  result.urls[0],
                                                  " [x%u]" % (len(result.urls)) if len(result.urls) > 1 else ""))
    return results_kept
438272
def artist_to_ref(artist):
    """"""
    if artist.name:
        name = artist.name
    else:
        name = 'Unknown artist'
    return Ref.directory(uri=artist.uri, name=name)
1046663
function collectionFind(filter, options) {
        if (!filter) {
            // TODO - limit of ten by
            return collections[ this['_collection'] ]
        }

        if ( typeof(filter) !== 'object' ) { // == findAll
            throw new Error('filter must be an object');
        } else {
            //console.log('search into ', this['_collection'], collections[ this['_collection'] ], collections);
            var content             = collections[ this['_collection'] ]
                , condition         = filter.count()
                , i                 = 0
                , found             = []
                , localeLowerCase   = '';

            for (var o in content) {
                for (var f in filter) {
                    localeLowerCase = ( typeof(filter[f]) != 'boolean' ) ? filter[f].toLocaleLowerCase() : filter[f];
                    if ( filter[f] && keywords.indexOf(localeLowerCase) > -1 && localeLowerCase == 'not null' && typeof(content[o][f]) != 'undefined' && typeof(content[o][f]) !== 'object' && content[o][f] != 'null' && content[o][f] != 'undefined' ) {
                        if (found.indexOf(content[o][f]) < 0 ) {
                            found[i] = content[o][f];
                            ++i
                        }

                    } else if ( typeof(content[o][f]) != 'undefined' && typeof(content[o][f]) !== 'object' && content[o][f] === filter[f] ) {
                        found[i] = content[o];
                        ++i
                    }
                }
            }
        }

        return found
    }
1179879
function search (query) {
  if (!allowSearch) {
    console.error('Assets for search still loading');
    return;
  }

  var resultDocuments = [];
  var results = index.search(query + '~2'); // fuzzy
  for (var i=0; i < results.length; i++){
    var result = results[i];
    doc = documents[result.ref];
    doc.summary = doc.text.substring(0, 200);
    resultDocuments.push(doc);
  }
  return resultDocuments;
}
1082591
def download_artist_by_search(self, artist_name):
        

        try:
            artist = self.crawler.search_artist(artist_name, self.quiet)
        except RequestException as exception:
            click.echo(exception)
        else:
            self.download_artist_by_id(artist.artist_id, artist.artist_name)
796572
def lookup_track(self, track):
        
        tracks = Track.objects.filter(title__iexact=track.title)
        for track_obj in tracks:
            for contributor in track_obj.get_primary_contributors(permitted=False):
                if contributor.title == track.artist:
                    return track_obj
        return None
763494
def get_album_artists(self, *args, **kwargs):
        
        args = tuple(['album_artists'] + list(args))
        return self.get_music_library_information(*args, **kwargs)
393622
def get_artists(self, *args, **kwargs):
        
        args = tuple(['artists'] + list(args))
        return self.get_music_library_information(*args, **kwargs)
719700
def _find_matching_collections_externally(collections, record):
    
    index, doc_type = RecordIndexer().record_to_index(record)
    body = {"doc": record.dumps()}
    results = current_search_client.percolate(
        index=index,
        doc_type=doc_type,
        allow_no_indices=True,
        ignore_unavailable=True,
        body=body
    )
    prefix_len = len('collection-')
    for match in results['matches']:
        collection_name = match['_id']
        if collection_name.startswith('collection-'):
            name = collection_name[prefix_len:]
            if name in collections:
                yield collections[name]['ancestors']
    raise StopIteration
70107
public void querySchema() {

    ResultSet results =
        session.execute(
            "SELECT * FROM simplex.playlists "
                + "WHERE id = 2cc9ccb7-6221-4ccb-8387-f22b6a1b354d;");

    System.out.printf("%-30s\t%-20s\t%-20s%n", "title", "album", "artist");
    System.out.println(
        "-------------------------------+-----------------------+--------------------");

    for (Row row : results) {

      System.out.printf(
          "%-30s\t%-20s\t%-20s%n",
          row.getString("title"), row.getString("album"), row.getString("artist"));
    }
  }
1219970
function search(user, pass, userArray) {
      return _.findWhere(userArray, { user: user, pass: pass });
    }
1323362
def get_albums(self):
        
        return itunespy.lookup(id=self.artist_id, entity=itunespy.entities['album'])[1:]
586106
def search_gallery(self, q):
        """"""
        url = self._base_url + "/3/gallery/search?q={0}".format(q)
        resp = self._send_request(url)
        return [_get_album_or_image(thing, self) for thing in resp]
397083
def search(self, string, default=None):
        """"""
        default = default if default else []
        result = [item[1] for item in self.container if item[0].search(string)]
        if self.ensure_mapping:
            assert len(result) < 2, "%s matches more than one pattern: %s" % (
                string,
                result,
            )
        return result if result else default
1010037
def search(self, s, stype=1, offset=0, total='true', limit=60):
        """"""
        action = uri + '/search/get'
        data = {
            's': s,
            'type': stype,
            'offset': offset,
            'total': total,
            'limit': 60
        }
        resp = self.request('POST', action, data)
        if resp['code'] == 200:
            return resp['result']['songs']
        return []