youtube / api-samples

Code samples for YouTube APIs, including the YouTube Data API, YouTube Analytics API, and YouTube Live Streaming API. The repo contains language-specific directories that contain the samples.
5.43k stars 2.97k forks source link

Search List - Keyword Phrases Returning Less Results #248

Open adam-hurwitz opened 5 years ago

adam-hurwitz commented 5 years ago

Expected

Adding a keyword phrase with the OR operator | in the YouTube API v3 search list request should return more results than without a keyword phrase because OR is inclusive.

ie: cryptocurrency|DigitalCash|digital+cash|dash is passed via the q parameter, and is expected to return at least the same or larger size JSON response of videos compared to the search without the keyword phrase such as cryptocurrency|DigitalCash|dash.

Documentation

The YouTube Search: list documentation does not mention keyword phrases explicitly for the q parameter.

Your request can also use the Boolean NOT (-) and OR (|) operators to exclude videos or to find videos that are associated with one of several search terms. For example, to search for videos matching either "boating" or "sailing", set the q parameter value to boating|sailing. Similarly, to search for videos matching either "boating" or "sailing" but not "fishing", set the q parameter value to boating|sailing -fishing. Note that the pipe character must be URL-escaped when it is sent in your API request. The URL-escaped value for the pipe character is %7C.

Implementation: Search Requests documentation mentions keyword phrases with the skateboarding+dog example, which is the syntax followed below using + in between keyword phrases' words.

Observed

No Keyword Phrases

Results in 40 - 43 videos after multiple tests.

Request where q parameter equals: Cryptocurrency|crypto|blockchain|digitalcurrency|bitcoin|BTC|ethereum|ETH|Dash|DashNews|DigitalCash|LLMQs|ChainLocks|DAPI|MakerDao|MKR|DAI|Tezos|XTZ|ETC|Ripple|XRP|BCH|EOS|Stellar|XLM|Litecoin|LTC|Cardano|ADA|IOTA|Monero|XMR|Zcash|Tether|USDT|ChanLink|LINK|BAT|0x|ZRX|omisego|OMG|Tron|TRX|Coinbase|Binance

Request: https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=50&order=viewCount&publishedAfter=2019-05-22T23%3A30%3A04.334000000Z&q=Cryptocurrency%7Ccrypto%7Cblockchain%7Cdigitalcurrency%7Cbitcoin%7CBTC%7Cethereum%7CETH%7CDash%7CDashNews%7CDigitalCash%7CLLMQs%7CChainLocks%7CDAPI%7CMakerDao%7CMKR%7CDAI%7CTezos%7CXTZ%7CETC%7CRipple%7CXRP%7CBCH%7CEOS%7CStellar%7CXLM%7CLitecoin%7CLTC%7CCardano%7CADA%7CIOTA%7CMonero%7CXMR%7CZcash%7CTether%7CUSDT%7CChanLink%7CLINK%7CBAT%7C0x%7CZRX%7Comisego%7COMG%7CTron%7CTRX%7CCoinbase%7CBinance&safeSearch=none&type=video&pageToken=&key={yourApiKey}

Keyword Phrases

Results in 8 videos after multiple tests.

Request where q parameter equals: Cryptocurrency|crypto|blockchain|DigitalCurrency|digital+currency|bitcoin|BTC|ethereum|ETH|Dash|DashNews|Dash+News|DigitalCash|Digital+Cash|LLMQs|ChainLock|DAPI|MakerDao|MKR|DAI|Tezos|XTZ|ETC|Ripple|XRP|BCH|EOS|Stellar|XLM|Litecoin|LTC|Cardano|ADA|IOTA|Monero|XMR|Zcash|Tether|USDT|ChainLink|LINK|BAT|0x|ZRX|omisego|OMG|Tron|TRX|Coinbase|Binance

Request: https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=50&order=viewCount&publishedAfter=2019-05-23T00%3A02%3A57.853000000Z&q=Cryptocurrency%7Ccrypto%7Cblockchain%7CDigitalCurrency%7Cdigital%2Bcurrency%7Cbitcoin%7CBTC%7Cethereum%7CETH%7CDash%7CDashNews%7CDash%2BNews%7CDigitalCash%7CDigital%2BCash%7CLLMQs%7CChainLock%7CDAPI%7CMakerDao%7CMKR%7CDAI%7CTezos%7CXTZ%7CETC%7CRipple%7CXRP%7CBCH%7CEOS%7CStellar%7CXLM%7CLitecoin%7CLTC%7CCardano%7CADA%7CIOTA%7CMonero%7CXMR%7CZcash%7CTether%7CUSDT%7CChainLink%7CLINK%7CBAT%7C0x%7CZRX%7Comisego%7COMG%7CTron%7CTRX%7CCoinbase%7CBinance&safeSearch=none&type=video&pageToken=&key={yourApiKey}

iteGH commented 2 years ago

Did YouTube API v3 pull test as a function of number of OR Boolean operators. The number of search hits increase with 1st and 2nd uses of OR (hit results: text1 < text1 OR text2 < text1 OR text2 OR text3), but using three or more OR statements, the hits begin to tail off as more OR operators are used for a given pull. Thus, in my analysis, using two OR operators gives max (non-duplicate) results for each pull. Curious why YT does this.

Arroyoale89 commented 2 years ago

On Jan 4, 2022 3:23 PM, iteGH @.***> wrote: Did YouTube API v3 pull test as a function of number of OR Boolean operators. The number of search hits increase with 1st and 2nd uses of OR (hit results: text1 < text1 OR text2 < text1 OR text2 OR text3), but using three or more OR statements, the hits begin to tail off as more OR operators are used for a given pull. Thus, in my analysis, using two OR operators gives max (non-duplicate) results for each pull. Curious why YT does this.

—Reply to this email directly, view it on GitHub, or unsubscribe.Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you are subscribed to this thread.Message ID: @.***>