Hey just wondering if anyone has run into geosearc...
# community-help
k
Hey just wondering if anyone has run into geosearch 'formatting' issues? Submitting this (using Angular-InstantSearch widgets):
Copy code
searchParameters = {
  hitsPerPage: 10,
  q         : '*',
  query_by  : 'title',
  facetFilters: ['locationCoordinates: (44.3387557, -79.6795558, 1000.1km)'],
}
And getting this: `Value of filter field `location`: must be in the
(-44.50, 170.29, 0.75 km)
or (56.33, -65.97, 23.82, -127.82) format.` I get this error while using instantsearch-adapter. Other search parameters work just fine (ex. hitsPerPage) Hitting the server with curl requests yields either the same error or 'bad request'. Fields are set as facets, and I've tried every possible combination of quotes, backticks, brackets, spaces, decimal points, etc I can think of. PS. feel free to hit me with Angular related Typesense questions 🙂
j
@Kenneth Koniouchine For geosearch, you want to use the `ais-configure` widget and then use aroundLatLng and aroundRadius parameters as described here.
The adapter will then take care of translating those into typesense queries
🙌 1
k
That seems to have done it! I must have been trying to convert the examples too literally and didn't see the aroundLatLng and aroundRadius parameters while searching. The only issue I had was figuring out how to specify the name of the field to a value other than '_geoloc'. For now I simply made by schema use the field name ais expects ("_geoloc"). For future inquiries, here is what I ended up doing: schema:
Copy code
myCollection = {
  'name': `${snapshot.id}`,
  'fields': [
    {"name": ".*", "type": "auto"},
    {'name': '_geoloc', 'type': 'geopoint', 'facet': true},
    {'name': 'category.lvl0', 'type': 'string', 'facet': true},
    {'name': 'category.lvl1', 'type': 'string',
      "optional": true, 'facet': true},
  ],
} as CollectionCreateSchema;
component.ts
Copy code
// region Typesense Configuration
config = {
  indexName: 'events',
  searchClient
} as InstantSearchConfig;

searchParameters = {
  hitsPerPage: 10,
  q         : '*',
  query_by  : 'title',
  aroundLatLng: '45.406431, -78.6848739',
  aroundRadius: 1000
}
// endregion
component.html
Copy code
<ais-instantsearch [config]="config" (change)="setHits($event)">
  <ais-configure
    [searchParameters]="searchParameters"
  ></ais-configure>

  <ais-search-box [searchAsYouType]="false"></ais-search-box>
  <ais-geo-search></ais-geo-search>

  <ais-hits>
    <ng-template #searchResults let-hits="hits" let-results="results">
      <div *ngFor="let hit of hits">
        {{hit.title}}
        <button (click)="likeEvent(hit.eventId)">Like</button>
      </div>
    </ng-template>
  </ais-hits>
</ais-instantsearch>
j
@Kenneth Koniouchine Here's how you configure the name of the geo lat/lng field when instantiating the adapter: https://github.com/typesense/typesense-instantsearch-adapter#geosearch
k
🤦‍♂️ I totally read that earlier and missed it! Thanks
🙂 1