This commit is contained in:
unknown 2020-12-14 18:51:10 +02:00
Родитель a22b6ae3c7
Коммит d588411647
11 изменённых файлов: 28 добавлений и 37 удалений

Просмотреть файл

@ -129,6 +129,13 @@
</configuration>
</plugin>
</plugins>
<resources>
<directory>samples/resources</directory>
<filtering>true</filtering>
<includes>
<include>image.jpg</include>
</includes>
</resources>
</build>
</project>

Просмотреть файл

@ -59,7 +59,7 @@ public class BingCustomSearchSample {
// If you do not have a customConfigId, you can also use 1 as your value when setting your environment variable.
final String customConfigId = System.getenv("AZURE_BING_SAMPLES_CUSTOM_CONFIG_ID");
//Custom Search Endpoint
String endpoint = System.getenv("BING_CUSTOM_SEARCH_ENDPOINT") + "/bingcustomsearch/v7.0/search";
String endpoint = System.getenv("BING_CUSTOM_SEARCH_ENDPOINT") + "/v7.0/custom";
ServiceClientCredentials credentials = new ServiceClientCredentials() {
@Override
public void applyCredentialsFilter(Builder builder) {

Просмотреть файл

@ -51,6 +51,7 @@ public class BingEntitySearchSample {
if (thing.entityPresentationInfo().entityScenario() == EntityScenario.DOMINANT_ENTITY) {
System.out.println("Searched for \"Satya Nadella\" and found a dominant entity with this description:");
System.out.println(thing.description());
System.out.println("\n");
hasDominateEntry = true;
break;
}
@ -104,6 +105,7 @@ public class BingEntitySearchSample {
} else {
System.out.println("Didn't see any data..");
}
System.out.println("\n");
break;
} catch (ErrorResponseException e) {
System.out.println(
@ -123,12 +125,12 @@ public class BingEntitySearchSample {
}
//=============================================================
// This will look up a single store "Microsoft Store" and print out its phone number.
// This will look up a single restaurant "john howie bellevue" and print out its phone number.
System.out.println("Searching for \"Microsoft Store\"");
System.out.println("Searching for \"john howie bellevue\"");
for (int i = 1; i <= 2; i++) {
try {
entityData = client.entities().search("Microsoft Store");
entityData = client.entities().search("john howie bellevue");
if (entityData.places() != null && entityData.places().value().size() > 0) {
// Some local entities will be places, others won't be. Depending on the data you want, try to cast to the appropriate schema
@ -136,7 +138,7 @@ public class BingEntitySearchSample {
Place store = (Place) entityData.places().value().get(0);
if (store != null) {
System.out.println("Searched for \"Microsoft Store\" and found a store with this phone number:");
System.out.println("Searched for \"john howie bellevue\" and found a store with this phone number:");
System.out.println(store.telephone());
} else {
System.out.println("Couldn't find a place!");
@ -144,6 +146,7 @@ public class BingEntitySearchSample {
} else {
System.out.println("Didn't see any data..");
}
System.out.println("/n");
break;
} catch (ErrorResponseException e) {
System.out.println(
@ -197,6 +200,7 @@ public class BingEntitySearchSample {
} else {
System.out.println("Didn't see any data..");
}
System.out.println("/n");
break;
} catch (ErrorResponseException e) {
System.out.println(
@ -215,28 +219,6 @@ public class BingEntitySearchSample {
}
//=============================================================
// This triggers a bad request and shows how to read the error response.
try {
SearchResponse errorQuery = client.entities().search("harry potter");
} catch (ErrorResponseException ex) {
// The status code of the error should be a good indication of what occurred. However, if you'd like more details, you can dig into the response.
// Please note that depending on the type of error, the response schema might be different, so you aren't guaranteed a specific error response schema.
System.out.println(
String.format("Exception occurred, status code %s with reason %s.", ex.response().code(), ex.response().message()));
// Attempting to parse the content as an ErrorResponse
ErrorResponse issue = ex.body();
if (issue != null && issue.errors() != null && issue.errors().size() > 0 ) {
Error error = issue.errors().get(0);
System.out.println(
String.format("Turns out the issue is parameter \"%s\" has an invalid value \"%s\". Detailed message is \"%s\"",
error.parameter(), error.value(), error.message()));
}
}
return true;
} catch (Exception f) {
System.out.println(f.getMessage());

Просмотреть файл

@ -68,7 +68,7 @@ public class BingImageSearchSample {
// then reopen your command prompt or IDE for changes to take effect.
final String subscriptionKey = System.getenv("BING_SEARCH_V7_SUBSCRIPTION_KEY");
// Add your Bing Search V7 endpoint to your environment variables.
String endpoint = System.getenv("BING_SEARCH_V7_ENDPOINT") + "/bing/v7.0/images/search";
String endpoint = System.getenv("BING_SEARCH_V7_ENDPOINT") + "/v7.0";
ServiceClientCredentials credentials = new ServiceClientCredentials() {
@Override

Просмотреть файл

@ -114,6 +114,7 @@ public class BingNewsSearchSample {
System.out.println(String.format("First news description: %s", firstNewsResult.description()));
System.out.println(String.format("First news published time: %s", firstNewsResult.datePublished()));
System.out.println(String.format("First news provider: %s", firstNewsResult.provider().get(0).name()));
System.out.println("\n");
} else {
System.out.println("Couldn't find news results!");
}

Просмотреть файл

@ -161,6 +161,7 @@ public class BingVideoSearchSample {
System.out.println(String.format("First video id: %s", firstVideoResult.videoId()));
System.out.println(String.format("First video name: %s", firstVideoResult.name()));
System.out.println(String.format("First video url: %s", firstVideoResult.contentUrl()));
System.out.println("\n");
} else {
System.out.println("Couldn't find video results!");
}
@ -185,6 +186,7 @@ public class BingVideoSearchSample {
String.format("First banner tile text: {firstBannerTile.Query.Text}"));
System.out.println(
String.format("First banner tile url: {firstBannerTile.Query.WebSearchUrl}"));
System.out.println("\n");
} else {
System.out.println("Couldn't find banner tiles!");
}
@ -225,7 +227,6 @@ public class BingVideoSearchSample {
System.out.println("Didn't see any trending video data..");
}
}
/**
* Main entry point.
*
@ -239,7 +240,7 @@ public class BingVideoSearchSample {
// then reopen your command prompt or IDE. If not, you may get an API key not found exception.
final String subscriptionKey = System.getenv("BING_SEARCH_V7_SUBSCRIPTION_KEY");
// Add your Bing Search V7 endpoint to your environment variables.
String endpoint = System.getenv("BING_SEARCH_V7_ENDPOINT") + "/bing/v7.0/videos/search";
String endpoint = System.getenv("BING_SEARCH_V7_ENDPOINT") + "/v7.0";
ServiceClientCredentials credentials = new ServiceClientCredentials() {
@Override

Просмотреть файл

@ -180,7 +180,7 @@ public class BingVisualSearchSample {
// Set the BING_SEARCH_V7_SUBSCRIPTION_KEY environment variable with your subscription key,
// then reopen your command prompt or IDE. If not, you may get an API key not found exception.
String subscriptionKey = System.getenv("BING_SEARCH_V7_SUBSCRIPTION_KEY");
String endpoint = System.getenv("BING_SEARCH_V7_ENDPOINT") + "/bing/v7.0/images/visualsearch";
String endpoint = System.getenv("BING_SEARCH_V7_ENDPOINT") + "/v7.0";
ServiceClientCredentials credentials = new ServiceClientCredentials() {
@Override
public void applyCredentialsFilter(Builder builder) {

Двоичные данные
samples/resources/image.jpg Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 48 KiB

Просмотреть файл

@ -19,14 +19,14 @@ public class Places extends SearchResultsAnswer {
* A list of local entities, such as restaurants or hotels.
*/
@JsonProperty(value = "value", required = true)
private List<Thing> value;
private List<Place> value;
/**
* Get a list of local entities, such as restaurants or hotels.
*
* @return the value value
*/
public List<Thing> value() {
public List<Place> value() {
return this.value;
}
@ -36,7 +36,7 @@ public class Places extends SearchResultsAnswer {
* @param value the value value to set
* @return the Places object itself.
*/
public Places withValue(List<Thing> value) {
public Places withValue(List<Place> value) {
this.value = value;
return this;
}

Просмотреть файл

@ -130,7 +130,7 @@ public class NewsImpl implements com.microsoft.bing.newssearch.NewsInterface {
final String countryCode = null;
final Integer count = null;
final Freshness freshness = null;
final String market = null;
final String market = "en-us";
final Integer offset = null;
final Boolean originalImage = null;
final SafeSearch safeSearch = null;
@ -550,7 +550,7 @@ public class NewsImpl implements com.microsoft.bing.newssearch.NewsInterface {
final String location = null;
final String countryCode = null;
final Integer count = null;
final String market = null;
final String market = "en-us";
final Integer offset = null;
final SafeSearch safeSearch = null;
final String setLang = null;

Просмотреть файл

@ -574,7 +574,7 @@ public class VideosImpl implements com.microsoft.bing.videosearch.VideosInterfac
final String clientIp = null;
final String location = null;
final String countryCode = null;
final String market = null;
final String market = "en-us";
final SafeSearch safeSearch = null;
final String setLang = null;
final Boolean textDecorations = null;