Skip to main content

πŸ” Search

The Search feature allows you to find places using either:

  • Text queries (e.g., "restaurants near me")
  • Geographic constraints (nearby search)

This feature is exposed through:

πŸ‘‰ See: ISearchService


🧩 Service​

public interface ISearchService {
Task<IReadOnlyList<PlaceSearchResult>> SearchByTextAsync(string textQuery);
Task<IReadOnlyList<PlaceSearchResult>> SearchByNearbyAsync(NearbyRequest nearbyRequest);
}

βš™οΈ Methods​

  • SearchByTextAsync β†’ search using a text query
  • SearchByNearbyAsync β†’ search using location

🧠 Notes​

  • Text search is quick and flexible
  • Nearby search gives more control and precision
  • Use nearby search when location matters (maps, GPS, etc.)

⚑ Examples​

var results = await searchService.SearchByTextAsync("coffee near Medellin");
var request = new NearbyRequestBuilder()
.WithTypes(["restaurant"])
.WithLocationRestriction(500, 40.7128, -74.0060)
.WithMaxResults(5)
.Build();

var results = await places.Search.SearchByNearbyAsync(request);

πŸ“¦ Models​

PlaceSearchResult​

Represents a place returned from a search query.

public sealed class PlaceSearchResult {
public string? PlaceId { get; internal set; }
public string? DisplayName { get; internal set; }
public IReadOnlyList<string> Types { get; internal set; } = [];
}

βš™οΈ Properties​

PropertyDescription
PlaceIdUnique identifier of the place
DisplayNameName of the place
TypesAssociated place types

πŸ’‘ Use IDetailsService if you need richer information.


🧾 Request​

NearbyRequest​

Represents a request for retrieving place suggestions.

public sealed class NearbyRequest {
public IReadOnlyList<string> IncludedTypes { get; internal set; } = [];
public int MaxResultCount { get; internal set; } = 1;
public LocationRestriction LocationRestriction { get; internal set; } = new();
}

βš™οΈ Properties​

PropertyDescription
IncludedTypesList of place types to include in the search
MaxResultCountMaximum number of results to return
LocationRestrictionGeographic restriction applied to the search

🧠 Notes​

  • Must be constructed using NearbyRequestBuilder

NearbyRequestBuilder​

Provides a fluent API for constructing nearby search requests.

public sealed class NearbyRequestBuilder {
public NearbyRequestBuilder WithTypes(IEnumerable<string> includedTypes);
public NearbyRequestBuilder WithMaxResults(int maxResults);
public NearbyRequestBuilder WithLocationRestriction(
double radius, double latitude, double longitude
);

public NearbyRequest Build();
}

βš™οΈ Configuration​

  • WithTypes(...) β†’ required, defines place types (e.g., restaurant, cafe)
  • WithMaxResults(...) β†’ optional, limits number of results
  • WithLocationRestriction(...) β†’ required, defines search area

⚠️ Validation​

  • Types must be provided
  • Location restriction must be defined
  • Max results must be greater than 0