YQL sample query returns max 260 results - yql

I am following YQL sample query
select * from local.search(500) where query="sushi" and location="san francisco, ca"
but I get 260 max count instead of 500. I tried also to use limit 500 after 'where' and different keywords, always get maximum 260 results. How do you increase it?

The underlying API that the local.search table uses (Yahoo! Local Search Web Service) has restrictions on the number of results returned.
The results parameter (the number of results "per page") has a maximum value of 20.
The start parameter (the offset at which to start) has a maximum value of 250.
Since you ask for the first 500 results, YQL makes multiple queries against the Local Search API returning 20 results at a time. Therefore the start values are 1, 21, 41, ... 241. This brings back 260 results, as you have seen.
Since the YQL query asks for more results, the next start value is tried (261) which is beyond the allowed range so the underlying service returns an error (with the message "invalid value: start (261) must be between 1 and 250"). If you turn on "diagnostics" in the YQL console, you will see the "Bad Request" being returned.
Nothing you do to the query will bring back more results than the underlying service allows.

I figured out, I was missing paging number, so 0++ will work
select * from local.search(0,500) where query="sushi" and location="san francisco, ca"

Related

Writing data over Influx HTTP API returns OK, but table is empty

I'm writing batched data over HTTP API like this
demo,state=idle
max=100.0,mean=20.0,event_type=0,probability=0.6,min=0.0 1529087114083
demo,state=idle
max=100.0,mean=80.0,event_type=1,probability=0.6,min=0.0 1529087114083
demo,state=idle
max=100.0,mean=20.0,event_type=2,probability=0.6,min=0.0 1529087114083
demo,state=idle
max=100.0,mean=80.0,event_type=3,probability=0.6,min=0.0 1529087114083
And the request returns 204 which is "ok" according to Influx API docs.
Still, when I want to check my data in admin
SELECT median("mean") AS "median_mean", mean("mean") AS "mean_mean"
FROM "sfb"."autogen"."demo" WHERE time > now() - 1h GROUP BY
:interval: FILL(null)
I get
Your query is syntactically correct but returned no results
Solved: need to specify proper timestamp precision - otherwise it calculates wrong data and data is not visible

YQL error into pressure when use u=c

good morning,
I starting to use a YQL for extract a weather condition for my town.
I live in Italy and set the query with u=c parameter, but in this case the pressure value is wrong.
If I request without u=c the query return:
atmosphere
pressure "1006.0"
but if I send a query with u=c return is:
atmosphere
pressure "34067.08"
my query is:
https://query.yahooapis.com/v1/public/yql?q=select * from weather.forecast where woeid in (select woeid from geo.places(1) where text="codogno,it") and u=c&format=json
I think Yahoo got it wrong. So if you requested u=c then it returns millibars but it is not expected value you must convert it to inch then you got the real millibars.
then if you requested u=f then it returns in but it is not as expected value it is a millibars so you must again convert it to an in.
Maybe we should consider a new provider.

SUM(LAST()) on GROUP BY

I have a series, disk, that contains a path (/mnt/disk1, /mnt/disk2, etc) and total space of a disk. It also includes free and used values. These values are updated at a specified interval. What I would like to do, is query to get the sum of the total of the last() of each path. I would also like to do the same for free and for used, to get a aggregate of the total size, free space, and used space of all of my disks on my server.
I have a query here that will get me the last(total) of all the disks, grouped by its path (for distinction):
select last(total) as total from disk where path =~ /(mnt\/disk).*/ group by path
Currently, this returns 5 series, each containing 1 row (the latest) and the value of its total. I then want to take the sum of those series, but I cannot just wrap the last(total) into a sum() function call. Is there a way to do this that I am missing?
Carrying on from my comment above about nested functions.
Building a toy example:
CREATE DATABASE FOO
USE FOO
Assuming your data is updated at intervals greater than[1] every minute:
CREATE CONTINUOUS QUERY disk_sum_total ON FOO
BEGIN
SELECT sum("total") AS "total_1m" INTO disk_1m_total FROM "disk"
GROUP BY time(1m)
END
Then push some values in:
INSERT disk,path="/mnt/disk1" total=30
INSERT disk,path="/mnt/disk2" total=32
INSERT disk,path="/mnt/disk3" total=33
And wait more than a minute. Then:
INSERT disk,path="/mnt/disk1" total=41
INSERT disk,path="/mnt/disk2" total=42
INSERT disk,path="/mnt/disk3" total=43
And wait a minute+ again. Then:
SELECT * FROM disk_1m_total
name: disk_1m_total
-------------------
time total_1m
1476015300000000000 95
1476015420000000000 126
The two values are 30+32+33=95 and 41+42+43=126.
From there, it's trivial to query:
SELECT last(total_1m) FROM disk_1m_total
name: disk_1m_total
-------------------
time last
1476015420000000000 126
Hope that helps.
[1] Picking intervals smaller than the update frequency prevents minor timing jitters from making all the data being accidentally summed twice for a given group. There might be some "zero update" intervals, but no "double counting" intervals. I typically run the query twice as fast as the updates. If the CQ sees no data for a window, there will be no CQ performed for that window, so last() will still give the correct answer. For example, I left the CQ running overnight and pushed no new data in: last(total_1m) gives the same answer, not zero for "no new data".

Twitter search api with hindi characters in the query returns 403 error

I am receiving 403 error from search api when using this query:
"सार्वजनिक स्वास्थ्य जॉन्स हॉपकिन्स विश्वविद्यालय" OR "एमए एन ए
पौष्टिक सहायता उत्पाद निगम" OR "मेडिसिन्स सैंस फ्रंटियर्स"
Error I have got from Twitter's api is:
{exceptionCode=[8e13056f-6071abbc], statusCode=403, message=Missing or
invalid url parameter., code=195, retryAfter=-1,
rateLimitStatus=RateLimitStatusJSONImpl{remaining=447, limit=450,
resetTimeInSeconds=1464249586, secondsUntilReset=695}, version=4.0.1}
It is strange because if I cut any element from original query it works.
The request I send is:
https://api.twitter.com/1.1/search/tweets.json?q=%22%E0%A4%B8%E0%A4%BE%E0%A4%B0%E0%A5%8D%E0%A4%B5%E0%A4%9C%E0%A4%A8%E0%A4%BF%E0%A4%95%20%E0%A4%B8%E0%A5%8D%E0%A4%B5%E0%A4%BE%E0%A4%B8%E0%A5%8D%E0%A4%A5%E0%A5%8D%E0%A4%AF%20%E0%A4%9C%E0%A5%89%E0%A4%A8%E0%A5%8D%E0%A4%B8%20%E0%A4%B9%E0%A5%89%E0%A4%AA%E0%A4%95%E0%A4%BF%E0%A4%A8%E0%A5%8D%E0%A4%B8%20%E0%A4%B5%E0%A4%BF%E0%A4%B6%E0%A5%8D%E0%A4%B5%E0%A4%B5%E0%A4%BF%E0%A4%A6%E0%A5%8D%E0%A4%AF%E0%A4%BE%E0%A4%B2%E0%A4%AF%22%20OR%20%22%E0%A4%8F%E0%A4%AE%E0%A4%8F%20%E0%A4%8F%E0%A4%A8%20%E0%A4%8F%20%E0%A4%AA%E0%A5%8C%E0%A4%B7%E0%A5%8D%E0%A4%9F%E0%A4%BF%E0%A4%95%20%E0%A4%B8%E0%A4%B9%E0%A4%BE%E0%A4%AF%E0%A4%A4%E0%A4%BE%20%E0%A4%89%E0%A4%A4%E0%A5%8D%E0%A4%AA%E0%A4%BE%E0%A4%A6%20%E0%A4%A8%E0%A4%BF%E0%A4%97%E0%A4%AE%22%20OR%20%22%E0%A4%AE%E0%A5%87%E0%A4%A1%E0%A4%BF%E0%A4%B8%E0%A4%BF%E0%A4%A8%E0%A5%8D%E0%A4%B8%20%E0%A4%B8%E0%A5%88%E0%A4%82%E0%A4%B8%20%E0%A4%AB%E0%A5%8D%E0%A4%B0%E0%A4%82%E0%A4%9F%E0%A4%BF%E0%A4%AF%E0%A4%B0%E0%A5%8D%E0%A4%B8%22&count=100&since=2016-05-23&with_twitter_user_id=true&include_entities=true
Do you have any idea what is wrong?
You just hit a query limit, you can get similar failures with even a simple repeated A OR B query once it gets over the max length.
https://dev.twitter.com/rest/reference/get/search/tweets
q: A UTF-8, URL-encoded search query of 500 characters maximum,
including operators. Queries may additionally be limited by
complexity.
Since you want an OR, you should probably query 3 times and union the results in your code.

Why is Neo4J telling me there is no spoon?

I am using Neo4J to represent texts; in the simplest case a text is a sequence of words joined by the relationship LEMMA_TEXT.
I am trying to find the Nth word after a known word, with a query that looks something like this.
MATCH (anchor)-[:LEMMA_TEXT*32]->(word)
WHERE id(anchor) = 3275
RETURN word
In one particular case, if I increase the path length to 33, I get this error:
Neo.DatabaseError.Statement.ExecutionFailure: There is no spoon.
And yet the following query returns the correct result.
MATCH (anchor)-[:LEMMA_TEXT*32]->(word)-[:LEMMA_TEXT]->(next)
WHERE id(anchor) = 3275
RETURN next
which demonstrates that the node I want exists and is reachable.
Where is the section of the manual that tells me how to bend the spoon with my mind? More importantly, what does this actually mean?!
If anything breaks at number like 33, it means that there was a restriction upto 32, why 32? 2^5.
It's not trivial that most of the restrictions are in a factor of 2, MongoDB document size cannot be more than 16 MB, on a collection there could be maximum index, no more than 64. etc.
why it works as 32 and then next, because till 32 it can achieve in one operation and for last one it can see the next one as another operation. But it cannot go for 33 in one operation.
Most of these restrictions are basically sanity check though and not really technical boundary.
As for why it is almost always a factor of 2, I want someone else to answer or in other words I don't know.
Have you tried splitting the landing and the search statements in 2?
Plus you should add the label for the text word (forormance)
Example:
MATCH (anchor)
WHERE id(anchor) = 3275
WITH anchor
MATCH (anchor)-[:LEMMA_TEXT*32]->(word)
RETURN word
You get the same error?

Resources