Search code examples
mongodbdatagripmongodb-indexes

MongoDB cannot set default_language for text index using DataGrip


I'm tring to create a text index for multiple fields in a mongodb collection called test but when i run this script in DataGrip

db.test.createIndex(
{"field1.subfield1": "text", "field1.subfield2": "text"},
{name : "my_test_index", default_language: "italian", weights:{"field1.subfield1": 2}})

throw this error

com.mongodb.mongosh.result.CommandException: unrecognized index model field: default_language

I tried running this script from the .js file in mongo shell as well with no success.

After other tests I noticed some problems with all the special options for the text index (default_language, language_override, weights, etc.)

MongoDB Instance Info

MongoDB shell version v4.4.3
  Build Info: {
    "version": "4.4.3",
    "gitVersion": "913d6b62acfbb344dde1b116f4161360acd8fd13",
    "openSSLVersion": "OpenSSL 1.1.1i 8 Dec 2020",
    "modules": [],
    "allocator": "tcmalloc",
    "environment": {
    "distmod": "debian10",
    "distarch": "x86_64",
    "target_arch": "x86_64"
  }
}

Where is the problem? Any idea?


Solution

  • It's not implemented in Java driver

    I created an issue for it https://youtrack.jetbrains.com/issue/DBE-12537

    I'll comment here when we release a driver with the fix