Skip to content

Commit fc5c05d

Browse files
chore: generated code for commit 47dd4bb5. [skip ci]
algolia/api-clients-automation@47dd4bb Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Clément Vannicatte <[email protected]>
1 parent 44f2e0b commit fc5c05d

File tree

1 file changed

+34
-85
lines changed

1 file changed

+34
-85
lines changed

README.md

Lines changed: 34 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
- Detailed logging
4848
- Injectable HTTP client
4949

50-
## Install
50+
## 💡 Getting Started
5151

5252
### Swift Package Manager
5353

@@ -62,21 +62,12 @@ If you're a framework author and use Swift API Client as a dependency, update yo
6262
let package = Package(
6363
// 9.0.0 ..< 10.0.0
6464
dependencies: [
65-
.package(url: "https://github.com/algolia/algoliasearch-client-swift", from: "9.0.0-alpha.0")
65+
.package(url: "https://github.com/algolia/algoliasearch-client-swift", from: "9.0.0-beta.6")
6666
],
6767
// ...
6868
)
6969
```
7070

71-
Import the Core package and the required client package to your source code files:
72-
73-
```swift
74-
#if canImport(Core)
75-
import Core
76-
#endif
77-
import Search // or Ingestion, for example
78-
```
79-
8071
### Cocoapods
8172

8273
[CocoaPods](https://cocoapods.org/) is a dependency manager for Cocoa projects.
@@ -112,85 +103,37 @@ github "algolia/algoliasearch-client-swift" ~> 9.0.0-alpha.0
112103

113104
If this is your first time using Carthage in the project, you'll need to go through some additional steps as explained [over at Carthage](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application).
114105

106+
You can now import the Algolia API client in your project and play with it.
115107

116-
## 💡 Getting Started
117-
118-
### Initialize the client
119-
120-
To start, you need to initialize the client. To do this, you need your **Application ID** and **API Key**.
121-
You can find both on [your Algolia account](https://www.algolia.com/api-keys).
108+
> Import the Core package and the required client package to your source code files:
122109
123110
```swift
124-
let client = SearchClient(applicationID: applicationID, apiKey: apiKey)
125-
```
126-
127-
### Push data
128-
129-
Without any prior configuration, you can start indexing contacts in the `contacts` index using the following code:
130-
131-
```swift
132-
struct Contact: Encodable {
133-
let firstname: String
134-
let lastname: String
135-
let followers: Int
136-
let company: String
137-
}
138-
139-
let contacts: [Contact] = [
140-
.init(firstname: "Jimmie", lastname: "Barninger", followers: 93, company: "California Paint"),
141-
.init(firstname: "Warren", lastname: "Speach", followers: 42, company: "Norwalk Crmc")
142-
]
143-
144-
for contact in contacts {
145-
let saveObjRes = try await client.saveObject(indexName: "contacts", body: contact)
146-
_ = try await client.getTask(indexName: "contacts", taskID: saveObjRes.taskID)
147-
}
148-
```
149-
150-
### Search
151-
152-
You can now search for contacts by `firstname`, `lastname`, `company`, etc. (even with typos):
153-
154-
```swift
155-
let searchParams = SearchParamsObject(query: "Jimmy")
156-
157-
let res = try await client.searchSingleIndex(indexName: "contacts", searchParams: .searchParamsObject(searchParams))
158-
159-
dump(res.hits[0])
160-
```
161-
162-
### Configure
111+
#if canImport(Core)
112+
import Core
113+
#endif
114+
import Search
163115

164-
Settings can be customized to tune the search behavior. For example, you can add a custom sort by number of followers to the already great built-in relevance:
116+
let client = try SearchClient(appID: "YOUR_APP_ID", apiKey: "YOUR_API_KEY")
165117

166-
```swift
167-
let indexSettings = IndexSettings(customRanking: ["desc(followers)"])
168-
try await client.setSettings(indexName: "contacts", indexSettings: indexSettings)
169-
```
170-
171-
You can also configure the list of attributes you want to index by order of importance (first = most important):
118+
// Add a new record to your Algolia index
119+
let response = try await client.saveObject(
120+
indexName: "<YOUR_INDEX_NAME>",
121+
body: ["objectID": "id", "test": "val"]
122+
)
172123

173-
**Note:** Since the engine is designed to suggest results as you type, you'll generally search by prefix.
174-
In this case the order of attributes is very important to decide which hit is the best:
124+
// Poll the task status to know when it has been indexed
125+
try await client.waitForTask(with: response.taskID, in: "<YOUR_INDEX_NAME>")
175126

176-
```swift
177-
let indexSettings = IndexSettings(searchableAttributes: ["lastname", "firstname", "company"])
178-
try await client.setSettings(indexName: "contacts", indexSettings: indexSettings)
127+
// Fetch search results, with typo tolerance
128+
let response: SearchResponses<Hit> = try await client
129+
.search(searchMethodParams: SearchMethodParams(requests: [SearchQuery.searchForHits(SearchForHits(
130+
query: "<YOUR_QUERY>",
131+
hitsPerPage: 50,
132+
indexName: "<YOUR_INDEX_NAME>"
133+
))]))
179134
```
180135

181-
For full documentation, visit the [Algolia's API Clients Automation documentation](https://api-clients-automation.netlify.app/docs/clients/introduction).
182-
183-
## 📝 Examples
184-
185-
You can find code samples in the [Algolia's API Clients Automation guides](https://api-clients-automation.netlify.app/docs/clients/guides/send-data-to-algolia).
186-
187-
## Contributing to this repository
188-
189-
The Algolia API clients are automatically generated, you can find everything here https://github.com/algolia/api-clients-automation
190-
191-
## 📄 License
192-
193-
Algolia Swift API Client is an open-sourced software licensed under the [MIT license](LICENSE).
136+
For full documentation, visit the **[Algolia Swift API Client](https://www.algolia.com/doc/api-client/getting-started/install/swift/)**.
194137

195138
## Notes
196139

@@ -212,8 +155,14 @@ You can use the old library with Swift by one of the following ways:
212155
- `pod 'AlgoliaSearch-Client-Swift', '~> 8.19'`
213156
- `pod 'AlgoliaSearch-Client-Swift', :git => 'https://github.com/algolia/algoliasearch-client-swift.git', :branch => 'swift-4'`
214157

215-
## Getting Help
158+
## ❓ Troubleshooting
159+
160+
Encountering an issue? Before reaching out to support, we recommend heading to our [FAQ](https://www.algolia.com/doc/api-client/troubleshooting/faq/swift/) where you will find answers for the most common issues and gotchas with the client. You can also open [a GitHub issue](https://github.com/algolia/api-clients-automation/issues/new?assignees=&labels=&projects=&template=Bug_report.md)
161+
162+
## Contributing
163+
164+
This repository hosts the code of the generated Algolia API client for Swift, if you'd like to contribute, head over to the [main repository](https://github.com/algolia/api-clients-automation). You can also find contributing guides on [our documentation website](https://api-clients-automation.netlify.app/docs/contributing/introduction).
165+
166+
## 📄 License
216167

217-
- **Need help**? Ask a question to the [Algolia Community](https://discourse.algolia.com/) or on [Stack Overflow](http://stackoverflow.com/questions/tagged/algolia).
218-
- **Encountering an issue?** Before reaching out to support, we recommend heading to our [FAQ](https://www.algolia.com/doc/api-client/troubleshooting/faq/swift/) where you will find answers for the most common issues and gotchas with the client.
219-
- **Found a bug?** You can open a [GitHub issue](https://github.com/algolia/algoliasearch-client-swift/issues).
168+
The Algolia Swift API Client is an open-sourced software licensed under the [MIT license](LICENSE).

0 commit comments

Comments
 (0)