Hi All! And thanks in advance for helping me troubleshoot
I am using app search with a gcp firestore search extension. ANd it automagically cruds according to my collection, but I can't search with a geo_distance filter. WIth just a string query it returns the correct data.
Here is my code:
elasticClientSearch.app.search({
engine_name: "swapperooni-search-engine-latest",
query: req.query['q'],
filters: {
geo_distance: {
distance: `${req.query['distance']}km` ,
location: {
lat: req.query['lat'],
lon: req.query['lon']
}
}
// filters: {
// // all: [
// location: {
// center: [`${req.query['lat']}` , `${req.query['lon']}` ],
// unit: 'km',
// from: 0,
// to: `${req.query['distance']}`
// }
// // ]
}
})
Tried both of the above. Returns errors like:
elasticsearch Client error {"errors":["Filters contains invalid keys for field: geo_distance; keys: distance and location","Filters must specify 'from' and/or 'to' in a range filter for field: geo_distance"]}
he api logs show:
Request details
Method
POST
Status
400
Timestamp
2023-06-21T19:10:00Z
User agent
elastic-transport-js/8.3.1 (linux 6.3.7-100.fc37.x86_64-x64; Node.js v16.16.0)
Request path
/api/as/v1/engines/swapperooni-search-engine-latest/search?query=aaaaaaa&filters%5Bgeo_distance%5D%5Bdistance%5D=5km&filters%5Bgeo_distance%5D%5Blocation%5D%5Blat%5D=47.6062095&filters%5Bgeo_distance%5D%5Blocation%5D%5Blon%5D=-122.3320708
Request body
Response body
{
"errors": [
"Filters contains invalid keys for field: geo_distance; keys: distance and location",
"Filters must specify 'from' and/or 'to' in a range filter for field: geo_distance"
]
}
which makes me think for some reason the query isn't getting parsed or something?
Mappings are as follows:
"location": {
"type": "text",
"fields": {
"date": {
"type": "date",
"format": "strict_date_time||strict_date",
"ignore_malformed": true
},
"delimiter": {
"type": "text",
"index_options": "freqs",
"analyzer": "iq_text_delimiter"
},
"enum": {
"type": "keyword",
"ignore_above": 2048
},
"float": {
"type": "double",
"ignore_malformed": true
},
"joined": {
"type": "text",
"index_options": "freqs",
"analyzer": "i_text_bigram",
"search_analyzer": "q_text_bigram"
},
"location": {
"type": "geo_point",
"ignore_malformed": true,
"ignore_z_value": false
},
"prefix": {
"type": "text",
"index_options": "docs",
"analyzer": "i_prefix",
"search_analyzer": "q_prefix"
},
"stem": {
"type": "text",
"analyzer": "iq_text_stem"
}
},
"index_options": "freqs",
"analyzer": "iq_text_base"
},
Any advice on how to get this to work is greatly appreciate. have tried a lot of variation, makes me think there is an issue with the gcp firestore search extentions...