Closed ml-evs closed 2 years ago
The limitation of the MongoDB community is that you can only have one text index per collection. We could circumvent this with an auxiliary text field that just concatenates all of the fields that are currently searched over in the free text search. With a sensible string format we can keep the same display format in the web app.
Ah yes, realized that in #47 I forgot to include the "script" that I used to build the index, but here it is:
from pymongo import MongoClient
from pydatalab.config import CONFIG
client = MongoClient(CONFIG.MONGO_URI)
db = client.datalabvue
response = db.items.create_index({ "$**": "text" })
Regarding #57, the index is here set up to run over all string fields in the db, so it will come up with results where the match is to the item_id, name, description, chemical formula, etc. I believe you can also fine tune this by specifying the weighting of the different fields, though that may be an atlas-only feature.
There is apparently something wrong with this script on the server, as the text index is only including the name field, not all string fields as it is.
There is apparently something wrong with this script on the server, as the text index is only including the name field, not all string fields as it is.
This is #65 - the indexes seem to be fine.
We should add these on API start-up.
https://docs.mongodb.com/v5.0/core/index-text/