wildcard query for searchable acting weird with spaces
See original GitHub issueDescribe the bug
Sample data:
[
{
id: 'uuid',
title: 'auto focus textfield'
},
{
id: 'uuid',
title: 'auto search label'
},
{
id: 'uuid',
title: 'auto label reports'
},
{
id: 'uuid',
title: 'disable auto commit on complete'
}
]
The query below works fine and returns all the fields data with “auto” in them,
{
searchMyModel (
filter: {
title: {
wildcard: "auto"
}
}
) {
items {
id
title
}
}
}
But when you start adding spaces:
{
searchMyModel (
filter: {
title: {
wildcard: "auto focus"
}
}
) {
items {
id
title
}
}
}
I’m expecting this to return:
[
{
id: 'uuid',
title: 'auto focus textfield'
}
]
but it returned:
[]
as it’s the only one with auto
and focus
on the title. I tried adding asterisk all over the place, *auto focus
, auto focus*
, *auto focus*
, auto*focus
, *auto*focus*
but none of them worked.
I’m thinking of it in a way that like %search%
operator works in MySQL, I might be thinking about it the wrong way but that’s the functionality we are looking for.
To Reproduce Steps to reproduce the behavior:
- Add sample model
MyModel @model @searchable {
id: ID!
title: String
}
- Insert the sample data seen above.
- Execute the queries seen above (aws appsync).
- See error
Expected behavior
See above
Screenshots N/A
Smartphone (please complete the following information):
Not particular to any device.
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
Additional context
See above.
Sample code
See above.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
@DavidBrear while not related to this ticket, from what I can tell you will likely run into performance issues for any queries beginning with a wildcard, see: https://www.elastic.co/guide/en/elasticsearch/reference/6.2/query-dsl-regexp-query.html and https://www.elastic.co/guide/en/elasticsearch/reference/6.2/query-dsl-wildcard-query.html
This issue has been automatically locked since there hasn’t been any recent activity after it was closed. Please open a new issue for related bugs.
Looking for a help forum? We recommend joining the Amplify Community Discord server
*-help
channels for those types of questions.