有什么方法可以使用qs npm将查询字符串转换为弹性云查询字符串?支持所有嵌套查询参数,大于或小于范围所有查询范围之间的值?
任何npm模块,git hub代码或代码段都可以执行此操作? 示例:对于我的api,我支持qs npm模块支持的所有查询参数,其中我的搜索api从弹性云中获取。
以防万一我查询为
?title=Resurgence&causes=General&location.city=Mysuru&latitude=12.9803047&longitude=77.62949349999997&distance=50000&pageNumber=0&pageSize=10& organisation._id=5c36dd152edb5028fd7655a4
然后将查询字符串由qs npm模块转换为json对象,并给出如下json对象
{"title":"Resurgence","causes":"General","location.city":"Mysuru","latitude":"12.9803047","longitude":"77.62949349999997","distance":"50000","pageNumber":"0","pageSize":"10","organisation._id":"5c36dd152edb5028fd7655a4"}
与弹性搜索中的搜索一样,我想将其转换为弹性搜索查询对象,如下所示。 所以我只是在寻找一个npm模块,它将qs模块的查询字符串json转换为弹性云查询主体?
{
"index": "researchArticles",
"from": 0,
"size": 10,
"body": {
"query": {
"bool": {
"must": [
{
"match": {
"status": "PUBLISHED"
}
},
{
"match": {
"title": {
"query": "Resurgence",
"operator": "or",
"prefix_length": 1
}
}
},
{
"match": {
"causes": {
"query": "General",
"operator": "or",
"prefix_length": 1
}
}
},
{
"match": {
"location.city": {
"query": "Bengaluru",
"operator": "or",
"prefix_length": 1
}
}
},
{
"match": {
"pageNumber": {
"query": "0",
"operator": "or",
"prefix_length": 1
}
}
},
{
"match": {
"pageSize": {
"query": "10",
"operator": "or",
"prefix_length": 1
}
}
},
{
"match": {
"organisation._id": {
"query": "5c36dd152edb5028fd7655a4",
"operator": "or",
"prefix_length": 1
}
}
}
],
"should": {
"range": {
"startDate": {
"gte": "now"
}
}
},
"filter": {
"geo_distance": {
"distance": "50000",
"location.geoSpatial": {
"lat": "12.9803047",
"lon": "77.62949349999997"
}
}
}
}
},
"sort": [
{
"_geo_distance": {
"location.geoSpatial": "12.9803047,77.62949349999997",
"order": "asc",
"unit": "m"
}
}
]
}
}