These are chat archives for Automattic/mongoose

24th
Feb 2018
Jafar Akhondali
@JafarAkhondali
Feb 24 2018 09:51
Hey folks, I'm kinda new to mongoose and gonna set textIndexes on multiple columns.
This is what I've done so far: ProductSchema.index({FaName:'text',EnName:'text'});
But when i get indexes with db.products.getIndexes()
It shows "default_language" : "english", i want to have different languages for my text indexes, Something like
FaName:{index:'text', lang:'pes'}
EnName:{index:'text', lang:'en'}
Kev
@lineus
Feb 24 2018 11:04
@JafarAkhondali I haven't ever done this before, but here are the docs on mongodb.
Kev
@lineus
Feb 24 2018 11:12
and Automattic/mongoose#4764 is what appears to be a relevant answer to your question found in the closed issues from the mongoose repo.
Jafar Akhondali
@JafarAkhondali
Feb 24 2018 11:17
@lineus Thanks, I've read docs of mongodb, I want an implemention in mongoose
The closed issue you gave is for setting one key only, Not multiple languages
Kev
@lineus
Feb 24 2018 11:38
my bad, I linked to the wrong page. Automattic/mongoose#4785
Kev
@lineus
Feb 24 2018 11:46
@JafarAkhondali for example
Jafar Akhondali
@JafarAkhondali
Feb 24 2018 14:25
@lineus The issue You've linked is for setting multiple fields only, Not multiple languages
Your gist also contains error

I think i've found the problem, According to docs Mongodb doesn't let us use multiple indexes with text type, Mongoose provide this functionality virtually by merging content of columns into a single field

        "name" : "FaName_text_EnName_text",

I'm not 100% sure about this yet :sweat_smile:

Kev
@lineus
Feb 24 2018 14:52
@JafarAkhondali mongodb not allowing multiple text indexes was the error in my gist (intentionally), and the answer in the issue I pointed out. Let me know how your solution works out