If I have an array containing a number of urls:
['http://www.abc.com', ..., 'http://www.xyz.com']
for each url, I would like to fetch the html with the following query:
select * from html where url=[url from array]
Question: do I need to make request to yql for every single url in the array or is there a way to send a single request to yql with all the urls and receive a bulk response ?
You could use the following query:
select * from html where url in ('http://www.yahoo.com','http://www.google.com')
Alternatively, you could also use yql.query.multi YQL table which allows you to combine different YQL queries.eg:
select * from yql.query.multi where queries="select * from html where url='http://www.google.com';select * from html where url='http://www.javarants.com/rss'"
Related
I have a base url of an API like this
http://host/api/categories
In my database categories are a tree based model. I'd like to be able to have an api where I can hit urls like
http://host/api/categories/delivery
http://host/api/categories/delivery/food
http://host/api/categories/delivery/medicine
How can I pull everything after the word "categories" as a single string (and split it myself) or as a list of strings? Essentially getting List("delivery","medicine") out of the third example would be great.
Super easy answer just use
pathPrefix("listJobCategories" / Segments) { query =>
and query will be List[String]
In Ruby on Rails, using NeoGraphy, I'm constructing a parameterized cypher query and getting back a result.
#results = $neo.execute_query(query, parameters)
Using gon, I put all these to the client and checked them out in the javascript console:
gon.results = #results
gon.search_query = query
gon.search_parameters = parameters
gon.search_query is just what I see in the .rb file, so I guess that means cypher takes that and takes the parameters and then creates the query. Can I get to the string version of the query that must be created by using the parameter values?
The reason I want this is so that I can paste it into the neo4j web admin console tool and tweak it.
Thanks!
Perhaps the simplest way to accomplish that is to write your own print method that given the query and the parameters would print the expanded query. And you can call it before / after the $neo.execute_query
I am experimenting with elastic search via the Elastic Search Head plugin.
The results are as expected when I submit a query via POST.
However when I try the same query using GET, I always get back all values in the index.
So : how to pass the query to the elastic search server via GET so I can use the search string in an URL?
If you send a GET the body is probably not even sent to elasticsearch, so you are basically sending no query to the _search endpoint, which is why you are getting everything back (of course only the first 10 results based on the default size parameter).
Have a look at the URI request, which allows you to send basic queries using the q parameter within the URI. You can use the Lucene query syntax and specify some other parameters listed in the linked page. If you then want to execute more advanced queries, you might want to express them as JSON queries in order to get all the benefits of the elasticsearch Query DSL, but you'd need to provide them as body of the request.
UPDATE
Looking deeper at the elasticsearch head plugin, the query is not sent as the request body when you select the GET method but within the URL itself and without specifying the name for the parameter, like this:
http://localhost:9200/_search&{"query":{"term":{"text":"john"}}}
That is probably a bug in the plugin itself and elasticsearch can't find the query, that's why you get all the results back. That means that only the POST method works while sending queries with elasticsearch head.
Elasticsearch allows to use both GET and POST for executing queries. If you use GET you can either send the query as body or use the source parameter like this:
http://localhost:9200/_search?source={"query":{"term":{"text":"john"}}}
I'm doing a very simple YQL statement:
select * from xml where url="http://www.wowhead.com/item=50278&xml"
The rest query looks like this (super long with crazy url escape codes):
http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20xml%20where%20url%3D%22http%3A%2F%2Fwww.wowhead.com%2Fitem%3D50278%26amp%3Bamp%3Bxml%22
So I'm trying to use the query alias to shorten it down. I know I can use something like url=#parameter but how would I do it so the item number is the variable and the rest query would look something like:
http://query.yahooapis.com/v1/public/yql/RVCA18/wowheadXML?item=50278
I appreciate the help :)
You can build the URL to the XML file using a URI Template (info, YQL uses the 03 draft). The YQL query to do that would look like the following.
select * from xml where url in (
select url from uritemplate
where template="http://www.wowhead.com/item={item}&xml" and item=#item
);
(Try this in the YQL console)
The next stage, which it looks like you already know how to do, is to alias the above query to wowheadXML and call it with the item value in the query string (example).
I'm wondering how you can use Yahoo Pipes to get any tweets than contain a url to link to that url when clicked, instead of linking to Twitter.
I made some assumptions.
You want the first URL if there are multiple links in the message
If there is no URL, you will skip the tweet
You only care about http and https links
The flow ends up:
1 Fetch Feed - Use twitter RSS
2 Filter - item.description Matches regex https?://
3 Rename - item.description Copy As link
4 Regex - In item.link replace ^.*?(https?://[\w:##%/;$()~?+-=\.&]+).*$ with $1 (s)
If you want to see all tweets, then the simplest thing is to split the feed at the top and filter the ones with and without URLs and only process the URL ones. Finally you can remerge the feeds before outputting.
If you want more url types, change the https?:// to (https?|ftp|etc):// in step 2 and 4
I made a sample here.