Python indexed mongodb, right?

{ "_id" : ObjectId("5bd6c4f3c3474d25ef31e224"), "unique_charcter" : [ "FqT9lRq7wdoSqjbfvQALU7mf4R0M" ], "name" : "-_2017-2018.3-14.pdf" }
{ "_id" : ObjectId("5bd6c4f3c3474d25ef31e225"), "unique_charcter" : [ "FoofNrPnYIIZVsyj65XUVUvjTR1Z" ], "name" : "-201810-25.pdf" }
{ "_id" : ObjectId("5bd6c4f3c3474d25ef31e226"), "unique_charcter" : [ "FgU-MGyutFQW3DOIZGbo3wWQHp72" ], "name" : "-_2017-2018.3-16.pdf" }
{ "_id" : ObjectId("5bd6c4f3c3474d25ef31e227"), "unique_charcter" : [ "lqlGn1hLyW_-waylmX1LEACcYlgu" ], "name" : "-2018-38.pdf" }
{ "_id" : ObjectId("5bd6c4f3c3474d25ef31e228"), "unique_charcter" : [ "lvde7RfjUU3cB47wMp4ZXWbaTduu" ], "name" : "-2017-110.pdf" }
{ "_id" : ObjectId("5bd6c4f3c3474d25ef31e229"), "unique_charcter" : [ "FlvvOS5Ezs1OoWs0s6Mg_zNMujsc" ], "name" : "--2018.3-15.pdf" }
{ "_id" : ObjectId("5bd6c4f3c3474d25ef31e22a"), "unique_charcter" : [ "FpRF3bsFmE-h1c0HPn7dAu3B8Usy" ], "name" : "-20182app:-2018.3-31.pdf" }
{ "_id" : ObjectId("5bd6c4f3c3474d25ef31e22b"), "unique_charcter" : [ "FuSlMQSZyMHootmuSoT3y4MKSs7x" ], "name" : "-app-2018.3-13.pdf" }

add index and insert
key_word = {"unique_charcter": unique_charcter [0], "name": item ["name"]}
self.xiaoMiQuanCollection.ensureIndex (key_word)
res = self.xiaoMiQuanCollection.find (key_word)

the code after adding the index is as follows
key_word = {"unique_charcter": unique_charcter [0], "name": item ["name"]}
index=self.xiaoMiQuanCollection.createIndex ({key_word:1})
res = self.xiaoMiQuanCollection.find (index)

Sep.27,2021

I don't know where to start. How about a clearer description? What is
key_word ? The format for indexing is usually {field: 1 > > , with 1 for ascending order and-1 for descending order. If key_word is in this format, then find must be wrong; conversely, if the syntax of find is satisfied, then ensureIndex must be in the wrong format.
in addition, does the "correct" you want mean whether the grammar is correct, or whether the result is correct? The acceptable grammar of JS is very loose, and most of the above writing methods will not report errors, and it is uncertain if you look up the results or not. It still depends on: what exactly is key_word ?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b38e02-2c140.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b38e02-2c140.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?