amplify-category-api
amplify-category-api copied to clipboard
GraphQL property of type Float creates a mappings type Long in OpenSearch when uses the @searchable directive in mock
How did you install the Amplify CLI?
npm
If applicable, what version of Node.js are you using?
v18.13.0
Amplify CLI Version
12.12.4
What operating system are you using?
Ubuntu 22.04
Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.
No manual changes made.
Describe the bug
Hello!
I have a model in my schema.graphql with a property named Value of Float type.
type MeasurementValue @searchable @model {
id: ID!
Time: String
Value: Float
}
When I try to make a aggregation query to get the sum or avg, for example, It returns a result with no float points.
Query:
query MyQuery {
searchMeasurementValues(
aggregates: {name: "sum", type: sum, field: Value}
) {
nextToken
total
aggregateItems {
name
result {
... on SearchableAggregateScalarResult {
__typename
value
}
}
}
}
}
Result:
{
"data": {
"searchMeasurementValues": {
"nextToken": "WyIwMmI4OTAxYS04MzczLTRmOWItYTM0NS04MjNjYmYyNTFlZTMiXQ==",
"total": 86,
"aggregateItems": [
{
"name": "sum",
"result": {
"__typename": "SearchableAggregateScalarResult",
"value": 2344
}
}
]
}
}
}
If I do a GET measurementvalue/_mapping, this is the result:
{
"measurementvalue" : {
"mappings" : {
"properties" : {
"Time" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"Value" : {
"type" : "long" <---- This type should be Float or Double
},
"__typename" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"createdAt" : {
"type" : "date"
},
"id" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"updatedAt" : {
"type" : "date"
}
}
}
}
}
The type of the generated index in OpenSearch is long, nor float or double.
Thanks.
Expected behavior
The type of the generated index in OpenSearch should be float, not long.
Reproduction steps
- Create a model with the @searchable directive and a Float property.
- Make an aggregation query which requires number operations (sum, max, min, avg).
Project Identifier
No response
Log output
# Put your logs below this line
Additional information
No response
Before submitting, please confirm:
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [X] I have removed any sensitive information from my code snippets and submission.