Skip to content

docs(java): small migration guide #934

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions website/docs/clients/guides/customized-client-usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ client.search(
.setHitsPerPage(50)
)
),
MyObject.class,
new RequestOptions()
// This header is added to the request
.addExtraHeader("additional-header", "hello")
Expand Down
15 changes: 10 additions & 5 deletions website/docs/clients/guides/filtering-your-search.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ client.search(
.setQuery("<YOUR_QUERY>")
.setFilters("actor:Scarlett Johansson")
)
)
),
Actor.class
);

// Only "Tom Cruise" or "Scarlett Johansson" actor
Expand All @@ -166,7 +167,8 @@ client.search(
.setQuery("<YOUR_QUERY>")
.setFilters("actor:Tom Cruise OR actor:Scarlett Johansson")
)
)
),
Actor.class
);

// Everything but "Nicolas Cage" actor
Expand All @@ -178,7 +180,8 @@ client.search(
.setQuery("<YOUR_QUERY>")
.setFilters("NOT actor:Nicolas Cage")
)
)
),
Actor.class
);
```

Expand Down Expand Up @@ -256,7 +259,8 @@ client.search(
.setQuery("<YOUR_QUERY>")
.addFacetFilters("actor:Scarlett Johansson")
)
)
),
Actor.class
);

// Only "Tom Cruise" or "Scarlett Johansson" actor
Expand All @@ -269,7 +273,8 @@ client.search(
.addFacetFilters("actor:Tom Cruise")
.addFacetFilters("actor:Scarlett Johansson")
)
)
),
Actor.class
);
```

Expand Down
6 changes: 4 additions & 2 deletions website/docs/clients/guides/retrieving-facets.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ client.search(
.addFacets("author")
.addFacets("genre")
)
)
),
MyObject.class
);
```

Expand All @@ -101,7 +102,8 @@ client.search(
.setQuery("<YOUR_QUERY>")
.addFacets("*")
)
)
),
MyObject.class
);
```

Expand Down
8 changes: 5 additions & 3 deletions website/docs/clients/guides/send-data-to-algolia.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,12 @@ $client->waitForTask(<YOUR_INDEX_NAME>, $response['taskID']);
<TabItem value="java">

```java
class Actor {
String name;
import com.algolia.model.search.*;

Actor(String name) {
class Actor extends Hit {
public String name;

public Actor(String name) {
this.name = name;
}
}
Expand Down
6 changes: 4 additions & 2 deletions website/docs/clients/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,14 @@ client.saveObject("<YOUR_INDEX_NAME>", body);
SearchMethodParams searchMethodParams = new SearchMethodParams();
SearchQueries requests = new SearchQueries();
requests.setIndexName("<YOUR_INDEX_NAME>");
// Typo tolerant search
requests.setQuery("my aloglia ojbect");
searchMethodParams.setRequests(requests);

try {
SearchResponse result = client.search(
searchMethodParams
SearchResponse<MyObject> result = client.search(
searchMethodParams,
MyObject.class
);
System.out.println(result);
} catch (AlgoliaRuntimeException e) {
Expand Down
16 changes: 11 additions & 5 deletions website/docs/clients/migration-guides/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ client.search(
.addAttributesToRetrieve("lastname")
.setHitsPerPage(50)
)
)
),
MyObject.class
);
```

Expand Down Expand Up @@ -153,8 +154,11 @@ const abTest = await abtestingClient.getABTest({
<TabItem value="java">

```java
// TODO
import com.algolia.api.AbtestingClient;
import com.algolia.model.abtesting.*;

AbtestingClient client = new AbtestingClient("<YOUR_APP_ID>", "<YOUR_API_KEY>");
ABTest abTest = client.getABTest(42);
```

</TabItem>
Expand Down Expand Up @@ -381,10 +385,12 @@ $client->batch(
<TabItem value="java">

```java
class Actor {
String name;
import com.algolia.model.search.*;

class Actor extends Hit {
public String name;

Actor(String name) {
public Actor(String name) {
this.name = name;
}
}
Expand Down
28 changes: 27 additions & 1 deletion website/docs/clients/migration-guides/java.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,30 @@
title: Java
---

WIP
### Methods targeting an `indexName`

Prior to the `initIndex` removal stated in the [common breaking changes](/docs/clients/migration-guides/#common-breaking-changes), all methods previously available at the `initIndex` level requires the `indexName` to be sent with the query.

That also mean you need to explicit the type you want to be returned from your queries, when it applies.

```java
import com.algolia.api.SearchClient;
import com.algolia.model.search.*;

SearchClient client = new SearchClient("<YOUR_APP_ID>", "<YOUR_API_KEY>");

client.search(
new SearchMethodParams()
.addRequests(SearchQuery.of(
new SearchForHits()
.setIndexName("<YOUR_INDEX_NAME>")
.setQuery("<YOUR_QUERY>")
)
),
MyObject.class
);
```




2 changes: 1 addition & 1 deletion website/docs/clients/migration-guides/javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: JavaScript
---

| Previous | Latest | Description |
| --------- | :------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|-----------|:---------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `search` | `searchClient` | Exported clients are suffixed by `Client`. |
| `destroy` | **removed** | This method has not been implemented in the new clients, if you feel the need for it, [please open an issue](https://github.com/algolia/api-clients-automation/issues/new?assignees=&labels=&template=Feature_request.md) |

Expand Down
10 changes: 5 additions & 5 deletions website/docs/clients/migration-guides/php.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
title: PHP
---

| Previous | Latest | Description |
| -------------------- | :------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `"algolia/algoliasearch-client-php": "^3.2"` | `"algolia/algoliasearch-client-php": "^4.0@alpha"` | **During the beta phase**, the clients are available under the package 4.x.x-alpha , you can find a full list [here](https://packagist.org/packages/algolia/algoliasearch-client-php). |
| `Algolia\AlgoliaSearch` | `Algolia\AlgoliaSearch\Api` | Exported clients have now the namespace suffixed by `Api`. |
| `Algolia\AlgoliaSearch\Cache\FileCacheDriver` | **removed** | This implementation of the `CacheInterface` is not available anymore in the Client. If you feel the need for it, [please open an issue](https://github.com/algolia/api-clients-automation/issues/new?assignees=&labels=&template=Feature_request.md) |
| Previous | Latest | Description |
|-----------------------------------------------|:---------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `"algolia/algoliasearch-client-php": "^3.2"` | `"algolia/algoliasearch-client-php": "^4.0@alpha"` | **During the beta phase**, the clients are available under the package 4.x.x-alpha , you can find a full list [here](https://packagist.org/packages/algolia/algoliasearch-client-php). |
| `Algolia\AlgoliaSearch` | `Algolia\AlgoliaSearch\Api` | Exported clients have now the namespace suffixed by `Api`. |
| `Algolia\AlgoliaSearch\Cache\FileCacheDriver` | **removed** | This implementation of the `CacheInterface` is not available anymore in the Client. If you feel the need for it, [please open an issue](https://github.com/algolia/api-clients-automation/issues/new?assignees=&labels=&template=Feature_request.md) |


### Usage
Expand Down