Comments (16)
I get the -999 error as well using the URLSessionAdaptorConfiguration and an elasticsearch URL using https. IT works with the NIO example. My URL and certificate are also valid. It seems like maybe the URLSession adapter is not using any of the default certificate validation.
from elasticswift.
@stomper3579 I believe you are talking about this
let match = try QueryBuilders.matchQuery().match(field: "myField", value: "MySearchValue").build()
QueryBuilders and Quries are part of ElasticSwiftQueryDSL
Did you tried
import ElasticSwiftQueryDSL
?
from elasticswift.
I did include that import yes.
It says: Value of type 'MatchQueryBuilder' has no member 'match'
from elasticswift.
@stomper3579 It looks like I missed some of the sections in README while updating it.
Please, refer:
from elasticswift.
Updated examples in ElasticSwiftExamples to 1.0.0-alpha.10
from elasticswift.
Thank you! That compiles without errors now. Unfortunately now I get the error:
Error Domain=NSURLErrorDomain Code=-999 "cancelled"
Here is my function based off of the readme.
I've checked the url and credentials with postman to confirm they are good.
func parse() {
let credentials: ClientCredential = BasicClientCredential(username: ES_USERNAME, password: ES_PASSWORD)
let settings = Settings(forHost: ES_URL_STRING, withCredentials: credentials, adaptorConfig: URLSessionAdaptorConfiguration.default)
let client = ElasticClient(settings: settings)
let queryBuilder = QueryBuilders.boolQuery()
do {
let match = try QueryBuilders.matchQuery().set(field: "last_name").set(value: "m").build()
queryBuilder.must(query: match)
let query = try queryBuilder.build()
let sort = SortBuilders.fieldSort("last_name")
.set(order: .asc)
.build()
let request = try SearchRequestBuilder()
.set(indices: "leads_primary")
//.set(types: "lead")
.set(query: query)
.set(sort: sort)
.build()
client.search(request, completionHandler: handler)
}
catch {
print("Unexpected error: \(error).")
}
}
func handler(_ result: Result<SearchResponse<String>, Error>) -> Void {
switch result {
case .failure(let error):
print("Error", error)
case .success(let response):
print("Response", response)
}
}
from elasticswift.
I will need a few more details about your setup.
- What is the target platform?
- Using cocopods/spm?
- Swift/Xcode version ?
from elasticswift.
Xcode 11.2.1 just iPhone
swift 4.2
cocoapods
pod 'ElasticSwift', '~> 1.0.0-alpha.10'
pod 'ElasticSwiftCore', '~> 1.0.0-alpha.10'
pod 'ElasticSwiftQueryDSL', '~> 1.0.0-alpha.10'
pod 'ElasticSwiftCodableUtils', '~> 1.0.0-alpha.10'
pod 'ElasticSwiftNetworking', '~> 1.0.0-alpha.10'
from elasticswift.
Not sure where all that strikethrough came from
from elasticswift.
strikethrough lines were because of ~>
from elasticswift.
As of v1.0.0-alpha.6
ElasticSwift requires swift 5.0
and above. Not sure how it's compiling for you maybe Xcode is handling it for you.
Since request execution is completely async and based on the above snippet client
is initialized inside parse
, the client
is deallocated shortly after it goes out of scope. As a result, any pending tasks are cancelled.
I would also recommend looking at example ios app here and thread here
from elasticswift.
Thank you for helping me in this. I'm using swift 5.0 and your example helped me clean up my code some. I'm now creating the client in ViewDidLoad.
my new function looks like this:
func parse() {
do {
let query = try QueryBuilders.matchQuery().set(field: "query").set(value: "mouse").build()
let request = try SearchRequestBuilder()
.set(indices: "leads_primary")
.set(size: 5)
.set(query: query)
.build()
client.search(request, completionHandler: handler)
}
catch {
print("Unexpected error: \(error).")
}
}
Unfortunately I'm still getting the 999 error. I've confirmed that I don't need a certificate and again I know that the credentials and URL are good as they've been tested in Postman.
Thanks again, I'd really appreciate it if you have any more suggestions.
from elasticswift.
I don’t see anything wrong with the function as such. If you could provide a example app which reproduces the error in a repo and share link here. I can clone and investigate.
from elasticswift.
afcdad1 Fixed ReadMe and updated examples to alpha.11
from elasticswift.
Funny, I am also seeing the same thing. Using an https
URL with URLSessionAdaptorConfiguration.default
. I'm using Xcode 12.5.1, and Swift 5.
from elasticswift.
Ok, after looking more into my issue it appears it's impossible to use HTTPS + URLSession adapter without a custom self-signed certificate. I'll file a separate issue.
from elasticswift.
Related Issues (20)
- ReIndexAPI Support HOT 1
- Use AsyncHTTPClient in ElasticSwiftNetworkingNIO
- Add missing features for SearchRequest HOT 1
- Count API Support HOT 1
- Explain API Support HOT 1
- Suggesters Support HOT 1
- Field Capabilities API HOT 1
- Ranking Evaluation API
- Search Template Support HOT 1
- Joining Queries Support HOT 1
- Geo Queries Support HOT 1
- Remove no longer necessary toDic() method
- Inconsistency in Enum case naming
- Specialized queries Support HOT 1
- Span Queries HOT 1
- Have you considered using Futures instead of callbacks? HOT 1
- Basic Cluster API support HOT 1
- Not possible to use server on HTTPS with a valid public certificate HOT 2
- ElasticsearchError(error: "Routing Error. The path you have requested is invalid.", status: nil)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elasticswift.