python-3.x - 获取 TypeError:如果未指定方向,则 key_or_list 必须是列表的实例
问题描述
所以我想在 pymongo 中使用$text
方法之后$nearSphere
的方法,但为此我收到此错误:TypeError: if no direction is specified, key_or_list must be an instance of list。这里有什么问题?
@app.route('/connect', methods=['GET', 'POST'])
def connect():
database = mongo.db.mylogin
mongo.db.mylogin.create_index([("location", pymongo.GEOSPHERE )])
request_books = database.find({ "location": { "$nearSphere": { "$geometry" : {"type" : "Point", "coordinates": [session['lang'], session['lat']]}, "$minDistance": 0, "$maxDistance" : 5000 } } })
mongo.db.mylogin.create_index( { "name": "text", "description": "text" } )
search = database.find_one({ "$text": {"$search" : "biology book"}})
return str(search)
解决方案
推荐阅读
- php - 用户池客户端 {id} 不存在
- java - 我的代码有什么问题。Decryption.txt 不接受 java 文件操作中的任何消息。?
- javascript - 如何在 Chrome 浏览器中使用 javascript 验证有效的 Date 对象
- php - 我想用 php (.htaccess) 重写一个 URL
- python - 使用 MongoDB 更改流时代码不运行
- c++ - 16X32 RGB Led矩阵,矩阵多重定义
- c# - c# linq 包含参数值
- amazon-web-services - 是否可以从雅典娜查询中删除存储在 S3 存储桶中的整个表?
- postgresql - k8s docker容器挂载主机,但输出日志文件失败
- javascript - 如何在Javascript中获取作为字符串公开的操作结果