Does Youtube API have "AND and OR" search and explicit match search? - ruby-on-rails

Does Youtube API allow me to do searches like
Search videos which have (in their title) strings both Lady Gaga AND (Cyrus OR Muse)
And does Youtube API allow me to do searches like
Search videos which have (in their title) string exactly Katy Perry. I don't want titles which have Katy Elizabeth Perry.
What's the most efficient code to write that type of search request? I want to code it using Ruby on rails.
I've gone through various introduction about how to search Youtube but they were mainly talking about other filtering things like relevance and view counts filtering.

And is supported with include and exclude just like the search query in the Web UI.
You can use -{query term} to exclude a query term. Or |{gaga} to OR.
like {lady -gaga} or in decoded form
https://www.googleapis.com/youtube/v3/search?part=snippet&q=lady+-gaga&key={YOUR_API_KEY}
You can also make separate calls, put results into sets and do all these operations in your client.

Related

exclude term in YouTube Data API without including term

I'm using the YouTube Data API's search.list method to return a list of videos by date. I'm interested in filtering out certain content without having to specify a search term. The documentation specifies that you can use the - operator as a Boolean NOT, but this only seems to work if I precede that with a search term, meaning I can do this:
q:'food -pizza'
which will return results for the query term 'food' but not 'pizza'. Now say I want it to return any result excluding pizza you'd think this would work:
q:'-pizza'
but this returns an empty Array (no results). Am I doing this wrong? is there a way to exclude certain terms without having to specify a specific search term to include before hand?

Filter #tag tweets for a specific account using Twitter Streaming API

I am able to get tweets from a specific account using the streaming API. I can also manage to get tweets for specific #tags like below:
endpoint.trackTerms(Lists.newArrayList("twitterapi", "#myTwitter"));
and
endpoint.trackTerms(Lists.newArrayList("twitterapi", "#yolo"));
I wonder how to merge these two queries as I want to get specific tweets (#yolo) from a specific user (#myTwitter)
Code can be found here
https://github.com/twitter/hbc
Take a look to Twitter's documentation on the streaming API, how to track terms:
A comma-separated list of phrases which will be used to determine what
Tweets will be delivered on the stream. A phrase may be one or more
terms separated by spaces, and a phrase will match if all of the terms
in the phrase are present in the Tweet, regardless of order and
ignoring case. By this model, you can think of commas as logical ORs,
while spaces are equivalent to logical ANDs (e.g. ‘the twitter’ is the
AND twitter, and ‘the,twitter’ is the OR twitter).
twitter-hbc only allows to track terms separated by commas, so if you do this,
endpoint.trackTerms(Lists.newArrayList("#myTwitter", "#yolo"));
You will actually be doing #myTwitter OR #yolo, take a look to the implementation of the method trackTerms,
/**
* #param terms a list of Strings to track. These strings should NOT be url-encoded.
*/
public StatusesFilterEndpoint trackTerms(List<String> terms) {
addPostParameter(Constants.TRACK_PARAM, Joiner.on(',').join(terms));
return this;
}
Instead of using trackTerms, you could add the terms directly to the endpoint like this,
endpoint.addPostParameter(Constants.TRACK_PARAM, Joiner.on(' ').join(Lists.newArrayList("twitterapi", "#yolo")));
Or of course you could create a new method.
Hope it helps.

Search a document in Elasticsearch by a list of Wildcarded statements on a single field

If I have documents in ElasticSearch that have a field called url and the contents of the url field are strings like "http://www.foo.com" or "http://www.bar.com/some/url/segment/the-page.html", is it possible to search for documents matching a list of wildcarded url fragments e.g., ["http://www.foo.", "http://www.bar.com//segment/.html", "://*bar.com/**"]?
If it is possible, what is the best approach to do this? I have explored wildcard query which only seems to support 1 fragment not multiple. Filters don't seem to support wildcarding as I have tried using * in a term filter without any luck.
To make it a little more complex, I'm also interested in being able to search by a lot of these fragments. I have come across terms filter lookup which seems like it is a good solution for dealing with many search terms, but I'm not sure wildcarding works with filters.
Any thoughts?

Filter by multiple resourceId's

Is there a way to query by multiple resourceId's using the .Net library?
For instance, usually I query for a single feed entry by resourceId like this:
DocumentsListQuery query = new DocumentsListQuery();
query.Uri = new Uri(string.Format("{0}/{1}", DocumentsListQuery.documentsBaseUri, doc.ResourceId));
DocumentsFeed feed = service.Query(query);
I'm wondering if there's some way to query for multiple documents by their resourceId's in a single query, instead of just fetching the whole list.
A single RESTful query can only return a single element or a feed, so there's no way to query by multiple resourceId's.
An alternative might be to specify a search query that restricts your results to the elements you want, but such search criteria only exist if your files have something in common that differentiates them from the other documents.
The documentation for search query in the Documents List API is available at https://developers.google.com/google-apps/documents-list/#searching_for_documents_and_files, but I'd also recommend you to take a look at the newer Drive API and at how it manages search:
https://developers.google.com/google-apps/documents-list/#searching_for_documents_and_files

Twitter: How can I form a set of related hashtags?

Now that I know I can no longer communicate with Twitter mashups out there, how can I create a set of related hashtags? For instance, how can I get all tags similar or related to yankees?
You might be interested in the mathematical equations for clustering related things.
Another, naive option, would be to just look at what hashtags frequently (subjective, I know) appear with a known hashtag and work from there.
You can use a term extractor on set of tweets returned by the topic of your choice. Eg: Get the list of tweets for search query 'yankees' and apply term extractor on the set of tweets you have. You can find Term Extraction APIs from Yahoo! and AlchemyAPI.
The result would set of important terms used in the tweets and you can use them with a hash to search for more related information.

Resources