meilisearch / meilisearch-swift

Swift client for the Meilisearch API
https://www.meilisearch.com
MIT License
93 stars 26 forks source link

Swift _geoBoundingBox implementation is missing #387

Closed willshelley closed 1 year ago

willshelley commented 1 year ago

We were trying to implement _geoBoundingBox filter after successfully implementing _geoRadius sort. We couldn't find any documentation for swift and currently can't get it to work. Understand that that should be an issue for the iOS-sdk.

maryamsulemani97 commented 1 year ago

Hi @willshelley,

Thank you for the issue. I'm transferring this to the integration guides repo as this is related to a missing Swift code sample(geosearch_guide_filter_usage_3). This code sample should have been added as part of https://github.com/meilisearch/integration-guides/issues/254

brunoocasali commented 1 year ago

Hi @willshelley, usually, when there is no code sample in the documentation, there is no implementation of that feature.

But I believe that in this case, is just a missing code sample. Can you try this?

  let searchParameters = SearchParameters(
      filter: '_geoBoundingBox([45.494181, 9.179175], [45.449484, 9.214024])'
  )
  client.index("restaurants").search(searchParameters) { (result: Result<Searchable<Restaurant>, Swift.Error>) in
      switch result {
      case .success(let searchResult):
          print(searchResult)
      case .failure(let error):
          print(error)
      }
  }
willshelley commented 1 year ago

Hi @brunoocasali , thanks for the quick reply. Realised I had our coordinates mixed up 😬, all worked as expected.

  let searchParameters = SearchParameters(
      query: "",
      filter: "_geoBoundingBox([45.494181, 9.179175], [45.449484, 9.214024])"
  )

  client.index("restaurants").search(searchParameters) { (result: Result<Searchable<Restaurant>, Swift.Error>) in
      switch result {
      case .success(let searchResult):
          print(searchResult)
      case .failure(let error):
          print(error)
      }
  }
brunoocasali commented 1 year ago

Amazing, good to know! 🎉