exclude term in YouTube Data API without including term - youtube

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?

Related

What is the difference between the filter and search query parameters in Microsoft Graph Mail API?

While I was looking at the documentation for query parameters here, I noticed that there were two query parameters that seemingly did the exact same thing: filter and search.
I'm just wondering what the difference is between them and when is one used over the other.
While they're similar, they operate a little differently.
$search uses Keyword Query Language (KQL) and is only supported by message and person collections (i.e. you can't use $search on most endpoints). By default, it searches multiple properties. Most importantly, $search is a "contains" search, meaning it will look for your search word/phrase anywhere within a string.
For example, /messages?$search="bacon" will search for the word "bacon" anywhere in the from, subject, or body properties.
Unlike $search, the $filter parameter only searches the specified property and does not support "contains" search. It also works with just about every endpoint. In most places, it supports the following operators: equals (eq), not equals (ne), greater than (gt), greater than or equals (ge), less than (lt), less than or equals (le), and (and), or (or), not (not), and (on some endpoints) starts with (startsWith).
For example, /messages?$filter=subject eq 'bacon' will return only messages where the subject is "bacon".
Both search and filter reduce the result set that you ultimately receive, however they operate in different ways.
Search operates on the query against the entire graph and reduces the amount of information a search query returns. This is often optimized for queries that search is good at, e.g. performing searches for items that can be indexed.
Filter operates on the much smaller result set returned by the search to provide more fine grain filtering. Separating this out allows filtering to perform tasks that would not be performant against the full collection.
This is indicated in Microsoft's documentation:
Search: Returns results based on search criteria.
Filter: Filters results (rows). (results that could be returned by search)
For performance purposes, it's good to use both if you can, search to narrow the results (e.g. using search indexes) and then do fine grain filtering on the returned results.

Prefix queries (*) in Azure Search don't return expected results

While searching on azure using Rest API provided by Microsoft Search API
Not behaving correctly when search string contains '#'.
Example: I've 3 rows in Azure Document
CES
CES#123
CES#1234
When My search string was CES* then all 3 were the result.
When My Search string was CES#123* then only one exact matching record was in result.
When My Search string was CES#* then there was no result.
As per my requirement in case of "CES#*" search string, all 3 records should be part of result set.
I've tried " "(space) in replacement of # it works, but my data contains # for search I need to maintain this.
I'm using SearchMode:Any.
This behavior is expected.
Query terms of prefix queries are not analyzed. Therefore, in your example with "CES#*" you are searching for term CES# while the # sign was stripped from the terms in the index: CES, 123, 1234.
Here is an excerpt from the How full text search works in Azure Search article:
Exceptions to lexical analysis
Lexical analysis applies only to query types that require complete
terms – either a term query or a phrase query. It doesn’t apply to
query types with incomplete terms – prefix query, wildcard query,
regex query – or to a fuzzy query. Those query types, including the
prefix query with term air-condition* in our example, are added
directly to the query tree, bypassing the analysis stage. The only
transformation performed on query terms of those types is lowercasing.

Find all comments matching a query on different youtbue videos

I know it is possible to list comments for a single video on youtbue but is it possible to find all comments on youtbue data api v3 that match a query?
For example if I search for "BMW" I find all comments on different videos with "BMW" in it. If it is not supported what would be a work around?
I am using python.
Comments: list Returns a list of comments that match the API
request parameters.
There is a filter parameter which will return the only certain comment ids, (why you would want to do this no idea)
id string The id parameter specifies a comma-separated list of
comment IDs for the resources that are being retrieved. In a comment
resource, the id property specifies the comment's ID.
For the Google methods that do allow you to do a string search (Which is what I think you are looking for) the parameter is normally q.
search.list has this option you can search for videos by text string, Google drive file.list also has it you can search for files that start with a name or type.
Answer: by checking the documentation we can see that it is not possible to find all comments on YouTube Data API v3 that match a string query.

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.

Does Youtube API have "AND and OR" search and explicit match search?

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.

Resources