В документации AWS для усиления определено, как вы можете искать географическое местоположение только путем создания собственного распознавателя:
https://aws -amplify.github.io / docs / cli / graphql? sdk = js # add-a-custom-resolver-that-target-a-Dynamodb-table-from-model
Но как найти это местоположение в сочетании с любым другим запросом?фильтр, например, как определенное имя.Так что найдите всех с именем X в местоположении X.
У меня есть этот шаблон:
"version": "2017-02-28",
"operation": "GET",
"path": "$indexPath.toLowerCase()",
"params": {
"body": {
"query": {
"bool" : {
"must" : [
{ match : { "name": $ctx.args.params.name }},
],
"filter" : {
"geo_distance" : {
"distance" : "${distance}km",
"location" : $util.toJson($ctx.args.location)
}
}
}
}
}
}
}
с этой схемой:
input paramsStringFilterInput {
ne: String
eq: String
match: String
matchPhrase: String
matchPhrasePrefix: String
multiMatch: String
exists: Boolean
wildcard: String
regexp: String
}
input ParamsInput {
name: paramsStringFilterInput
monday: Boolean
}
type ZVLConnection {
items: [ZVL]
total: Int
nextToken: String
}
type Query {
nearbyZVL(params: ParamsInput, location: LocationInput!, km: Int): ZVLConnection
}
Я получаю эту ошибку с этим запросом:
query getProfiles{
nearbyZVL(
location: {
lat:51.848388,
lon: 5.447252
},
km: 12,
params:{
name: { match: "Ramon" }
}
){
total,
items {
id
name
}
}
}
{
"data": {
"nearbyZVL": null
},
"errors": [
{
"path": [
"nearbyZVL"
],
"data": null,
"errorType": "MappingTemplate",
"errorInfo": null,
"locations": [
{
"line": 2,
"column": 3,
"sourceName": null
}
],
"message": "Unable to parse the JSON document: 'Unexpected character ('m' (code 109)): was expecting double-quote to start field name\n at [Source: (String)\"\n{\n \"version\": \"2017-02-28\",\n \"operation\": \"GET\",\n \"path\": \"/zorgverlener/doc/_search\",\n \"params\": {\n \"body\": {\n \"query\": {\n \"bool\" : {\n \"must\" : [\n { match : { \"name\": Ramon }},\n ],\n \"filter\" : {\n \"geo_distance\" : {\n \"distance\" : \"12km\",\n \"location\" : {\"lat\":51.848388,\"lon\":5.447252}\n \"[truncated 86 chars]; line: 11, column: 28]'"
}
]
}