get Google search suggestions while entering text - search

so i want to experiment with Google's search suggestion feature for word/phrase completion.
I.e. stick the functionality of typing a search on their home page into a text editor for starters.
is it possible to request these Google search suggestions with their REST API? Or somehow?

You could use one of the following URLs to get search suggestions from Google:
1. URL used by the suggestion box on the home page
http://www.google.com/complete/search?hl=en&js=true&qu=sugge
The query part is the qu parameter. A sample response would be:
window.google.ac.h(["sugge",[["suggest","200,000,000 results","0"],["suggestion box","27,500,000 results","1"],["suggestion","84,300,000 results","2"],["suggest friends on facebook","73,100,000 results","3"],["suggested calorie intake","1,940,000 results","4"],["suggestive","12,400,000 results","5"],["suggestion boxes","997,000 results","6"],["suggested weight for height and age","72,600,000 results","7"],["suggest synonym","2,490,000 results","8"],["suggestopedia","79,300 results","9"]]])
2. URL used by the Google toolbar
http://toolbarqueries.google.com/complete/search?q=sugge&output=toolbar&hl=en
The query is obviously the q parameter. This has the advantage of returning XML data, that is easier and more portable in terms of parsing the result:
<?xml version="1.0"?>
<toplevel>
<CompleteSuggestion><suggestion data="suggest"/><num_queries int="200000000"/></CompleteSuggestion>
<CompleteSuggestion><suggestion data="suggestion box"/><num_queries int="27500000"/></CompleteSuggestion>
<CompleteSuggestion><suggestion data="suggestion"/><num_queries int="84300000"/></CompleteSuggestion>
<CompleteSuggestion><suggestion data="suggest friends on facebook"/><num_queries int="73100000"/></CompleteSuggestion>
<CompleteSuggestion><suggestion data="suggested calorie intake"/><num_queries int="1940000"/></CompleteSuggestion>
<CompleteSuggestion><suggestion data="suggestive"/><num_queries int="12400000"/></CompleteSuggestion>
<CompleteSuggestion><suggestion data="suggestion boxes"/><num_queries int="997000"/></CompleteSuggestion>
<CompleteSuggestion><suggestion data="suggested weight for height and age"/><num_queries int="72600000"/></CompleteSuggestion>
<CompleteSuggestion><suggestion data="suggest synonym"/><num_queries int="2490000"/></CompleteSuggestion>
<CompleteSuggestion><suggestion data="suggestopedia"/><num_queries int="79300"/></CompleteSuggestion>
</toplevel>

Related

Oracle BI Report based on Excel template has no data when called through ReportService?

Oracle BI Publisher 12.2.1.4.0
I have a set of reports that I want to run using runReport Report Service. All the reports are working well when started within browser. The ones based on excel template when run through Report Service has just a header row with column labels. No data at all. Those based on BI template when asked for "xlsx format" through Report Service are all ok.
Those whose templates are created in excel (2019) using Oracle BI Publisher Desktop 12.2.1.4.0 add-on work ok unless called with SOAP envelope runReport action.
I'm doing something wrong, but could not find what. Not sure if the problem is in passing/formating parameters (dates especialy), or something else is missing or wrong in my SOAP:
<?xml version="1.0" encoding="utf-8"?>
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap-env:Body>
<ns0:RunReport xmlns:ns0="http://xmlns.oracle.com/oxp/service/v2">
<ns0:reportRequest>
<ns0:attributeCalendar>Gregorian</ns0:attributeCalendar>
<ns0:attributeFormat>excel</ns0:attributeFormat>
<ns0:attributeLocale>hr-Hr</ns0:attributeLocale>
<ns0:attributeTemplate>_TO_EXCEL_WEEKS_Cards.xls</ns0:attributeTemplate>
<ns0:flattenXML>true</ns0:flattenXML>
<ns0:parameterNameValues>
<ns0:listOfParamNameValues>
<ns0:item>
<ns0:name>DateFrom</ns0:name>
<ns0:values>
<ns0:item>2022-05-01T00:00:00.000+02:00</ns0:item>
</ns0:values>
</ns0:item>
<ns0:item>
<ns0:name>DateTo</ns0:name>
<ns0:values>
<ns0:item>2022-05-28T00:00:00.000+02:00</ns0:item>
</ns0:values>
</ns0:item>
<ns0:item>
<ns0:name>DateDeliveredTo</ns0:name>
<ns0:values>
<ns0:item>2022-05-28T00:00:00.000+02:00</ns0:item>
</ns0:values>
</ns0:item>
<ns0:item>
<ns0:name>Marcet</ns0:name>
<ns0:values>
<ns0:item>*</ns0:item>
</ns0:values>
</ns0:item>
</ns0:listOfParamNameValues>
</ns0:parameterNameValues>
<ns0:reportAbsolutePath>/MKTP/06-Sell/70_Offer/Reports/70_20_WEEKS_TO_EXCEL_TODAY_2022_REPORT.xdo</ns0:reportAbsolutePath>
<ns0:sizeOfDataChunkDownload>-1</ns0:sizeOfDataChunkDownload>
<ns0:byPassCache>True</ns0:byPassCache>
</ns0:reportRequest>
<ns0:userID>username</ns0:userID>
<ns0:password>password</ns0:password>
</ns0:RunReport>
</soap-env:Body>
</soap-env:Envelope>
I did try different attributeFormat tags (it works only when "excel", otherwise error), tryed to change the flattenXML tag (no data with true or false). Template is very simple with one group of repeating records and the header is always there, so there is not the problem with template name/location.
XDO_METADATA:
Data Constraints:
XDO_?XDOFIELD1? <?DOCTYPE?>
XDO_?XDOFIELD2? <?DOC_ID?>
XDO_?XDOFIELD3? <?STATUS?>
XDO_?XDOFIELD4? <?ORDER_ID?>
XDO_?XDOFIELD5? <?DOC_YEAR?>
XDO_?XDOFIELD6? <?DOC_NUM?>
XDO_?XDOFIELD7? <?DOC_DATE?>
...
...
XDO_GROUP_?XDOG1? <xsl:for-each select=".//G_1"> </xsl:for-each>
All the other reports (pdf-s) working ok whatever way they are run.
Thanks for your time...
Found it. The problem is parameter in BI defined as DATE. Changed it to text, adjusted the WHERE clause in dataset to something like
column Between To_Date(date_param1, 'dd.mm.yyyy') And To_Date(date_param2, 'dd.mm.yyyy')
and shortend the date parameter values in SOAP Envelope. It works now.
Anyway, I would like to know if there is a solution where I could keep my parameters in BI to stay of date type. This is a lot of boring things to do.

Google Custom Search API returns different total number of results

Google Custom Search API returns a different total number of results compared when I normally use my web browser to search google.
On the Custom Search Control Panel, Search the entire web is turned ON. I followed this set-up, it says 'Note that results may not match the results you'd get by searching on Google Web Search',
why is that?
Here is my code:
def main():
service = build("customsearch", "v1",
developerKey="my-key")
res = service.cse().list(
q='allintitle: hotels tokyo',
cx='my-key',
num=10,
).execute()
pprint.pprint(res)
if __name__ == '__main__':
main()
results :
searchInformation': {'formattedSearchTime': '0.41',
'formattedTotalResults': '5,260',
'searchTime': 0.408312,
'totalResults': '5260'}
Normal browser results :
Any idea why this is happening?
In case it is of use still, I had this problem and for me it turned out that I was setting the "dateRestrict" variable to 14 days in the Python call, meaning that the results were, of course different.

Piwik custom dimension in segment

We use Piwik cloud (innocraft.com) for analytics and have a custom dimension called channel_perm_id with scope Visit, it's called dimension1 and is transmitted via JS Tracking API. Using the piwik admin panel we can verify that the dimension is set correctly and transmitted by each visitor.
Now we want to query based on this dimension1 aka channel_perm_id:
curl -i https://###.innocraft.cloud/index.php?segment=dimension1==2ceb64954d4e46f49bc6afa310cf92f&token_auth=###&format=xml&date=today&period=day&idSite=8&module=API&method=VisitsSummary.get
The important part is
segment=dimension1==2ceb64954d4e46f49bc6afa310cf92f
which causes this query to return an empty response:
<result>
<nb_uniq_visitors>0</nb_uniq_visitors>
<nb_users>0</nb_users>
<nb_visits>0</nb_visits>
<nb_actions>0</nb_actions>
<nb_visits_converted>0</nb_visits_converted>
<bounce_count>0</bounce_count>
<sum_visit_length>0</sum_visit_length>
<max_actions>0</max_actions>
<bounce_rate>0%</bounce_rate>
<nb_actions_per_visit>0</nb_actions_per_visit>
<avg_time_on_site>0</avg_time_on_site>
</result>
Without the segment parameter the response looks like:
<result>
<nb_uniq_visitors>1</nb_uniq_visitors>
<nb_users>0</nb_users>
<nb_visits>6</nb_visits>
<nb_actions>0</nb_actions>
<nb_visits_converted>0</nb_visits_converted>
<bounce_count>6</bounce_count>
<sum_visit_length>2469</sum_visit_length>
<max_actions>0</max_actions>
<bounce_rate>100%</bounce_rate>
<nb_actions_per_visit>0</nb_actions_per_visit>
<avg_time_on_site>412</avg_time_on_site>
</result>
It looks like the custom dimension is somehow not aggregated in piwik.
But if we use the Live module (Live.getCounters instead of VisitsSummary.get), the query works fine.
So we think it has something to do with the scope maybe.
Any ideas are highly appreciated!

Twitter search: OR with Tags - but how?

I cannot search the twitter API for tweets which contain one of multiple tags.
Like: q="#tag1 OR #tag2 OR #tag3"
If I leave away the hashes and only search for words, the OR-ing works. For tags they don't.
When I only use spaces, the search terms will be AND-ed, what shrinks the result...
I use the twitter4j library with:
Twitter rest = new TwitterFactory().getInstance();
Query query = new Query();
query.setQuery("#win | #fail");
QueryResult result = rest.search(query);
Isn't it possible, or didn't i use it correctly?
Might just be easier to use twitter's REST API. You'll want to use the search query. Here's an example search url searching for #LA, #NYC or #Boston. Note the spaces and #s are all URL encoded. Just pop a URL like that into a getJSON call like below and you can easily extract your values from the returned JSON object as in the example.
var requestedData = "http://search.twitter.com/search.json?q=%23LA%20OR%20%23NYC%20OR%20%23Boston%22&callback=?"
$.getJSON(requestedData,function(ob)
{
var firstTweet = ob.results[0].text;
var firstTweeter = ob.results[0].from_user;
}
From there it's just a matter of looping through your results and pulling the appropriate fields which are all outlined in the JSON file if you simply visit that example search link in your browser! I don't know this TwitterFactory API but its possible they haven't updated to Twitter's new API or they're just not URL encoding appropriately. Good luck!
Try to use OR operator instead of "|":
query.setQuery("#win OR #fail");
See available Twitter search API operators here:
Using the Twitter Search API

Google Local Search and Markers

I'm following the code located at this page:
http://code.google.com/apis/ajax/playground/#localsearch_with_markers
the search the demo shows is:
// Execute an initial search
searchControl.execute('pizza');
How can I get it to search more than one term? For example something equivalent to:
// Execute an initial search
searchControl.execute('pizza');
searchControl.execute('coffee');
This method will only return the 'coffee' results. It completely ignores 'pizza'.
From reviewing this demo it appears to be possible...
http://code.google.com/apis/ajax/playground/#the_hello_world_of_local_search
if you look at the following code:
// Specify search quer(ies)
localSearch.execute('coffee New York NY');
and change it to:
// Specify search quer(ies)
localSearch.execute('pizza');
localSearch.execute('coffee');
It will return both pizza and coffe results. Any ideas to get this to show up on the map though?

Resources