Searchanalytics Query JAVA API v3 (Google WebMaster Tools) - java

I am trying to implement Google Webmasters Searchanalytics Query using using the Java API but i did not found any Java sample to use , in Google website here there is only Python samples for Searchanalytics Query , and they did not say that it's not available in Java API.
I found this class Webmasters.Searchanalytics.Query in the Java API which I assume that is equivalent to the Python function searchanalytics.query() but i did not found any implementation of it.
My question if it is possible to query data from Google Search Console using the Java API??
if yes i wounder if there is someone who can provide a Java sample, something like the Python sample provided by Google here.
Thank you in advance.

I succeded to implement Webmasters.Searchanalytics.Query
as follow
first you need to create your QueryRequest using the SearchAnalyticsQueryRequest class example:
private static SearchAnalyticsQueryRequest createSearchAnalyticsQueryRequest() {
SearchAnalyticsQueryRequest searQueryRequest = new SearchAnalyticsQueryRequest();
searQueryRequest.setStartDate("2016-04-10");
searQueryRequest.setEndDate("2016-04-20");
List<String> dimensions = new ArrayList<String>();
dimensions.add("page");
dimensions.add("query");
dimensions.add("country");
dimensions.add("device");
dimensions.add("date");
searQueryRequest.setDimensions(dimensions);
return searQueryRequest;
}
then executing the query as follow :
public static String Query(String site,
SearchAnalyticsQueryRequest searQueryRequest) throws Exception {
Webmasters.Searchanalytics.Query query = service.searchanalytics()
.query(site, searQueryRequest);
SearchAnalyticsQueryResponse queryResponse = query.execute();
return queryResponse.toPrettyString();
}

I think You missed it. here. Actually all you need to do is to click the Java link on the left.

Related

How to implement the Google Distance Matrix API in Java without using the HTTP request method

I am aware of the fact that I am able to use a HTTP request to use the distance matrix API (i.e. https://maps.googleapis.com/maps/api/distancematrix/json?origins=42.11622,78.10112&destinations=40.82231,72.224166&key=YOUR_API_KEY)
But I would like to simply use the Java API instead. From my understanding the first step is to create a GeoApiContext and this seems to be where I am failing. I have tried the following code:
private static GeoApiContext context = new GeoApiContext.Builder().apiKey("MyKey").queryRateLimit(500).build();
However I am just met with the following compile error:
java.land.NoClassDefFoundError: com/google/common/util/concurrent/RateLimiter
Any help on the matter would be appreciated. The plan is to use this to create a DistanceMatrix API request if that helps.
check out this link you may find it useful... there are code examples
https://www.programcreek.com/java-api-examples/index.php?api=com.google.maps.model.DistanceMatrix

How to retrieve more than 50 items using Azure Mobile

I'm using Android Studio and talk to a cloud-based Azure database. I know about the query limit of 50 and want to circumvent this. I use this query:
private List<ItemInfo> retrieveItemNumList() throws ExecutionException, InterruptedException {
return mItemInfoTable.select("Item_Number", "Item_Description").execute().get();
}
I've already found solutions such as:
[Queryable(MaxTop = 1000)]
public IQueryable<Place> GetAll()
However, this is a .NET solution while I am using Node.js. Also, I'm a complete noob so I don't know how to access the back ends functions of Azure. Could someone walk me through how to enable a query of 1000?
Thanks.
This question was answered on the MSDN forums today - https://social.msdn.microsoft.com/Forums/en-US/5efee2d6-417c-4d48-99d5-b8836d733a3e/override-50-row-limit-for-android-app?forum=azuremobile
#JamieWang, You can use the function MobileServiceTable.top(int top) to Sets the number of records to return.
If without the top function, according to the description of REST API here,
By default, Mobile Services returns only 50 records in a query.
As reference, there is an offical tutorial which you can refer to the subsection "How to: Return data in pages" of the section How to: Query data from a mobile service to know how to use.
So your code should be modified as below.
private List<ItemInfo> retrieveItemNumList() throws ExecutionException, InterruptedException {
return mItemInfoTable.select("Item_Number", "Item_Description").top(1000).execute().get();
}

How to call solr analysis api in java?

Is there a way to call solrs analysis api in java using solr-core and get the analyzed tokens.
Analysis api takes fieldName or fieldType and values and give the analyzed tokens.
Is there a way to get those tokens from java?
I found the following link: FieldAnalysisRequestHandler, But I could not get any examples to use it.
In the Admin UI (for which the FieldAnalysisRequestHandler is meant) you can call it by selecting a core and then go to the "Analysis" entry.
See https://cwiki.apache.org/confluence/x/UYDxAQ or https://cwiki.apache.org/confluence/x/FoDxAQ for that.
From a client (which I guess you mean, as you tagged this question with solrj) you need to call the correct URL.
Typically the FieldAnalysisRequestHandler is bound to /analysis/field, see your solrconfig.xml.
From Solrj it should work like this:
SolrQuery query = new SolrQuery();
solrQuery.setRequestHandler("/analysis/field");
solrQuery.set("analysis.fieldtype", "mytype");
solrQuery.set("analysis.fieldvalue", "myval");
QueryResponse solrResponse = solrServer.query(solrQuery);
But it doesn't seem like there's a great support for this in Solrj, probably because it's meant to be called from the Solr Admin UI as mentioned.

How to Know Model Type using AWS Java SDK for Machine Learning

I am using AWS Java SDK to generate RealTime Predictions. To get the output of prediction i need to know what kind of machine learning model is being used is it binary , regression or multiclass. I have only the model id which i can use to locate model.Is there any API or some other way through which i can know the model type in my application.
I have searched through the documentation but haven't found anything that suits my requirement.
You can get the model type by calling the GetMLModel API.
AmazonMachineLearningClient client = ...;
GetMLModelRequest request = new GetMLModelRequest().withMLModelId("...");
client.getMLModel(request).getMLModelType();

Twitter4j FilterQuery language() method missing

I'm using Twitter4j to access the Twitter streaming API, and I want to limit the tweets I get from the sample stream to English language tweets. I had thought that the way to do this would be as follows, based on the Javadoc:
FilterQuery fq = new FilterQuery();
String[] lang = { "en" };
fq.language(lang);// = "test";
twitterStream.filter(fq);
But, when I try and run that, I get a compiler error saying the FilterQuery objects don't have a public language method. Does anyone know what's going on?
Edit: I'm using version 3.0.3 of the JAR file
That feature has not been implemented yet. There's an open ticket TFJ-764 as part of the 3.0.4 for supporting tweet's metadata.

Categories