Skip to content

Commit da3b5f8

Browse files
authored
Remove README Sample (Azure#19566)
Remove README sample and test
1 parent 09f428d commit da3b5f8

File tree

5 files changed

+19
-75
lines changed

5 files changed

+19
-75
lines changed

sdk/search/azure-search-documents/README.md

Lines changed: 12 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -161,35 +161,8 @@ SearchAsyncClient searchAsyncClient = new SearchClientBuilder()
161161

162162
### Send your first search query
163163

164-
To get running immediately, we're going to connect to a well-known sandbox Search service provided by Microsoft. This
165-
means you do not need an Azure subscription or Azure Cognitive Search service to try out this query.
166-
167-
<!-- embedme ./src/samples/java/com/azure/search/documents/ReadmeSamples.java#L122-L144 -->
168-
```java
169-
// We'll connect to the Azure Cognitive Search public sandbox and send a
170-
// query to its "nycjobs" index built from a public dataset of available jobs
171-
// in New York.
172-
String serviceName = "azs-playground";
173-
String indexName = "nycjobs";
174-
String apiKey = "252044BE3886FE4A8E3BAA4F595114BB";
175-
176-
// Create a SearchClient to send queries
177-
String serviceEndpoint = String.format("https://%s.search.windows.net/", serviceName);
178-
AzureKeyCredential credential = new AzureKeyCredential(apiKey);
179-
SearchClient client = new SearchClientBuilder()
180-
.endpoint(serviceEndpoint)
181-
.credential(credential)
182-
.indexName(indexName)
183-
.buildClient();
184-
185-
// Let's get the top 5 jobs related to Microsoft
186-
client.search("Microsoft", new SearchOptions().setTop(5), Context.NONE).forEach(searchResult -> {
187-
SearchDocument document = searchResult.getDocument(SearchDocument.class);
188-
String title = (String) document.get("business_title");
189-
String description = (String) document.get("job_description");
190-
System.out.printf("The business title is %s, and here is the description: %s.%n", title, description);
191-
});
192-
```
164+
To get running with Azure Cognitive Search first create an index following this [guide][search-get-started-portal].
165+
With an index created you can use the following samples to begin using the SDK.
193166

194167
## Key concepts
195168

@@ -244,7 +217,7 @@ Let's explore them with a search for a "luxury" hotel.
244217
`SearchDocument` is the default type returned from queries when you don't provide your own. Here we perform the search,
245218
enumerate over the results, and extract data using `SearchDocument`'s dictionary indexer.
246219

247-
<!-- embedme ./src/samples/java/com/azure/search/documents/ReadmeSamples.java#L148-L153 -->
220+
<!-- embedme ./src/samples/java/com/azure/search/documents/ReadmeSamples.java#L122-L127 -->
248221
```java
249222
for (SearchResult searchResult : searchClient.search("luxury")) {
250223
SearchDocument doc = searchResult.getDocument(SearchDocument.class);
@@ -258,7 +231,7 @@ for (SearchResult searchResult : searchClient.search("luxury")) {
258231

259232
Define a `Hotel` class.
260233

261-
<!-- embedme ./src/samples/java/com/azure/search/documents/ReadmeSamples.java#L156-L177 -->
234+
<!-- embedme ./src/samples/java/com/azure/search/documents/ReadmeSamples.java#L130-L151 -->
262235
```java
263236
public class Hotel {
264237
private String id;
@@ -286,7 +259,7 @@ public class Hotel {
286259

287260
Use it in place of `SearchDocument` when querying.
288261

289-
<!-- embedme ./src/samples/java/com/azure/search/documents/ReadmeSamples.java#L180-L185 -->
262+
<!-- embedme ./src/samples/java/com/azure/search/documents/ReadmeSamples.java#L154-L159 -->
290263
```java
291264
for (SearchResult searchResult : searchClient.search("luxury")) {
292265
Hotel doc = searchResult.getDocument(Hotel.class);
@@ -304,7 +277,7 @@ The `SearchOptions` provide powerful control over the behavior of our queries.
304277

305278
Let's search for the top 5 luxury hotels with a good rating.
306279

307-
<!-- embedme ./src/samples/java/com/azure/search/documents/ReadmeSamples.java#L189-L194 -->
280+
<!-- embedme ./src/samples/java/com/azure/search/documents/ReadmeSamples.java#L163-L168 -->
308281
```java
309282
SearchOptions options = new SearchOptions()
310283
.setFilter("rating ge 4")
@@ -324,15 +297,15 @@ There are multiple ways of preparing search fields for a search index. For basic
324297
`List<SearchField>`. There are three annotations `SimpleFieldProperty`, `SearchFieldProperty` and `FieldBuilderIgnore`
325298
to configure the field of model class.
326299

327-
<!-- embedme ./src/samples/java/com/azure/search/documents/ReadmeSamples.java#L268-L269 -->
300+
<!-- embedme ./src/samples/java/com/azure/search/documents/ReadmeSamples.java#L242-L243 -->
328301
```java
329302
List<SearchField> searchFields = SearchIndexClient.buildSearchFields(Hotel.class, null);
330303
searchIndexClient.createIndex(new SearchIndex("index", searchFields));
331304
```
332305

333306
For advanced scenarios, we can build search fields using `SearchField` directly.
334307

335-
<!-- embedme ./src/samples/java/com/azure/search/documents/ReadmeSamples.java#L218-L264 -->
308+
<!-- embedme ./src/samples/java/com/azure/search/documents/ReadmeSamples.java#L192-L238 -->
336309
```java
337310
List<SearchField> searchFieldList = new ArrayList<>();
338311
searchFieldList.add(new SearchField("hotelId", SearchFieldDataType.STRING)
@@ -389,7 +362,7 @@ In addition to querying for documents using keywords and optional filters, you c
389362
your index if you already know the key. You could get the key from a query, for example, and want to show more
390363
information about it or navigate your customer to that document.
391364

392-
<!-- embedme ./src/samples/java/com/azure/search/documents/ReadmeSamples.java#L206-L207 -->
365+
<!-- embedme ./src/samples/java/com/azure/search/documents/ReadmeSamples.java#L180-L181 -->
393366
```java
394367
Hotel hotel = searchClient.getDocument("1", Hotel.class);
395368
System.out.printf("This is hotelId %s, and this is hotel name %s.%n", hotel.getId(), hotel.getName());
@@ -401,7 +374,7 @@ You can `Upload`, `Merge`, `MergeOrUpload`, and `Delete` multiple documents from
401374
There are [a few special rules for merging](https://docs.microsoft.com/rest/api/searchservice/addupdate-or-delete-documents#document-actions)
402375
to be aware of.
403376

404-
<!-- embedme ./src/samples/java/com/azure/search/documents/ReadmeSamples.java#L211-L214 -->
377+
<!-- embedme ./src/samples/java/com/azure/search/documents/ReadmeSamples.java#L185-L188 -->
405378
```java
406379
IndexDocumentsBatch<Hotel> batch = new IndexDocumentsBatch<>();
407380
batch.addUploadActions(Collections.singletonList(new Hotel().setId("783").setName("Upload Inn")));
@@ -418,7 +391,7 @@ to `false` to get a successful response with an `IndexDocumentsResult` for inspe
418391
The examples so far have been using synchronous APIs, but we provide full support for async APIs as well. You'll need
419392
to use [SearchAsyncClient](#create-a-searchclient).
420393

421-
<!-- embedme ./src/samples/java/com/azure/search/documents/ReadmeSamples.java#L198-L202 -->
394+
<!-- embedme ./src/samples/java/com/azure/search/documents/ReadmeSamples.java#L172-L176 -->
422395
```java
423396
searchAsyncClient.search("luxury")
424397
.subscribe(result -> {
@@ -509,5 +482,6 @@ This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For m
509482
[create_search_service_cli]: https://docs.microsoft.com/cli/azure/search/service?view=azure-cli-latest#az-search-service-create
510483
[HttpResponseException]: https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/core/azure-core/src/main/java/com/azure/core/exception/HttpResponseException.java
511484
[status_codes]: https://docs.microsoft.com/rest/api/searchservice/http-status-codes
485+
[search-get-started-portal]: https://docs.microsoft.com/azure/search/search-get-started-portal
512486

513487
![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-java%2Fsdk%2Fsearch%2Fazure-search-documents%2FREADME.png)

sdk/search/azure-search-documents/src/samples/java/com/azure/search/documents/ReadmeSamples.java

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -118,32 +118,6 @@ public void handleErrorsWithSyncClient() {
118118
}
119119
}
120120

121-
public void sandBoxConnection() {
122-
// We'll connect to the Azure Cognitive Search public sandbox and send a
123-
// query to its "nycjobs" index built from a public dataset of available jobs
124-
// in New York.
125-
String serviceName = "azs-playground";
126-
String indexName = "nycjobs";
127-
String apiKey = "252044BE3886FE4A8E3BAA4F595114BB";
128-
129-
// Create a SearchClient to send queries
130-
String serviceEndpoint = String.format("https://%s.search.windows.net/", serviceName);
131-
AzureKeyCredential credential = new AzureKeyCredential(apiKey);
132-
SearchClient client = new SearchClientBuilder()
133-
.endpoint(serviceEndpoint)
134-
.credential(credential)
135-
.indexName(indexName)
136-
.buildClient();
137-
138-
// Let's get the top 5 jobs related to Microsoft
139-
client.search("Microsoft", new SearchOptions().setTop(5), Context.NONE).forEach(searchResult -> {
140-
SearchDocument document = searchResult.getDocument(SearchDocument.class);
141-
String title = (String) document.get("business_title");
142-
String description = (String) document.get("job_description");
143-
System.out.printf("The business title is %s, and here is the description: %s.%n", title, description);
144-
});
145-
}
146-
147121
public void searchWithDynamicType() {
148122
for (SearchResult searchResult : searchClient.search("luxury")) {
149123
SearchDocument doc = searchResult.getDocument(SearchDocument.class);

sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/SearchTestBase.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import static com.azure.search.documents.TestHelpers.BLOB_DATASOURCE_NAME;
5353
import static com.azure.search.documents.TestHelpers.HOTEL_INDEX_NAME;
5454
import static com.azure.search.documents.TestHelpers.SQL_DATASOURCE_NAME;
55+
import static com.azure.search.documents.indexes.DataSourceSyncTests.FAKE_AZURE_SQL_CONNECTION_STRING;
5556

5657
/**
5758
* Abstract base class for all Search API tests
@@ -66,14 +67,6 @@ public abstract class SearchTestBase extends TestBase {
6667

6768
protected static final TestMode TEST_MODE = initializeTestMode();
6869

69-
// The connection string we use here, as well as table name and target index schema, use the USGS database
70-
// that we set up to support our code samples.
71-
//
72-
// ASSUMPTION: Change tracking has already been enabled on the database with ALTER DATABASE ... SET CHANGE_TRACKING = ON
73-
// and it has been enabled on the table with ALTER TABLE ... ENABLE CHANGE_TRACKING
74-
private static final String AZURE_SQL_CONN_STRING_READONLY_PLAYGROUND =
75-
"Server=tcp:azs-playground.database.windows.net,1433;Database=usgs;User ID=reader;Password=EdrERBt3j6mZDP;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;"; // [SuppressMessage("Microsoft.Security", "CS001:SecretInline")]
76-
7770
private static final String FAKE_DESCRIPTION = "Some data source";
7871

7972
static final String HOTELS_DATA_JSON = "HotelsDataArray.json";
@@ -370,7 +363,7 @@ protected SearchIndexerDataSourceConnection createTestSqlDataSourceObject() {
370363
protected SearchIndexerDataSourceConnection createTestSqlDataSourceObject(
371364
DataDeletionDetectionPolicy dataDeletionDetectionPolicy, DataChangeDetectionPolicy dataChangeDetectionPolicy) {
372365
return SearchIndexerDataSources.createFromAzureSql(testResourceNamer.randomName(SQL_DATASOURCE_NAME, 32),
373-
AZURE_SQL_CONN_STRING_READONLY_PLAYGROUND, "GeoNamesRI", FAKE_DESCRIPTION, dataChangeDetectionPolicy,
366+
FAKE_AZURE_SQL_CONNECTION_STRING, "GeoNamesRI", FAKE_DESCRIPTION, dataChangeDetectionPolicy,
374367
dataDeletionDetectionPolicy);
375368
}
376369

sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/indexes/DataSourceSyncTests.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public class DataSourceSyncTests extends SearchTestBase {
3939
"DefaultEndpointsProtocol=https;AccountName=NotaRealAccount;AccountKey=fake;";
4040
private static final String FAKE_COSMOS_CONNECTION_STRING =
4141
"AccountEndpoint=https://NotaRealAccount.documents.azure.com;AccountKey=fake;Database=someFakeDatabase";
42+
public static final String FAKE_AZURE_SQL_CONNECTION_STRING =
43+
"Server=tcp:fakeUri,1433;Database=fakeDatabase;User ID=reader;Password=fakePassword;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;";
4244

4345
private final List<String> dataSourcesToDelete = new ArrayList<>();
4446
private SearchIndexerClient client;
@@ -268,7 +270,8 @@ public void updateDataSourceIfNotChangedSucceedsWhenResourceUnchanged() {
268270
assertNotEquals(originalETag, updatedETag);
269271
}
270272

271-
@Test
273+
// TODO (alzimmer): Re-enable this test once live resource deployment is configured.
274+
//@Test
272275
public void createDataSourceReturnsCorrectDefinition() {
273276
SoftDeleteColumnDeletionDetectionPolicy deletionDetectionPolicy =
274277
new SoftDeleteColumnDeletionDetectionPolicy()

sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/indexes/IndexersManagementSyncTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public class IndexersManagementSyncTests extends SearchTestBase {
6565
private SearchIndexClient searchIndexClient;
6666

6767
private String createDataSource() {
68-
SearchIndexerDataSourceConnection dataSource = createTestSqlDataSourceObject();
68+
SearchIndexerDataSourceConnection dataSource = createBlobDataSource();
6969
searchIndexerClient.createOrUpdateDataSourceConnection(dataSource);
7070

7171
dataSourcesToDelete.add(dataSource.getName());

0 commit comments

Comments
 (0)