0

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?

2 Answers2

1

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

  • Thanks, I saw that this problem is present in all special options for text indexes except for the name. – Leonardo Bravi Feb 08 '21 at 09:15
  • We released mongo-jdbc-driver 1.11, you may update it on Datasource config page in IDE. It new supports all createIndex options. See JMongosh release notes: https://github.com/kornilova203/mongosh/releases/tag/v0.4 – Liudmila Kornilova Feb 15 '21 at 10:49
0

Probably the problem is a bug in DataGrip or its driver.

SOLUTION: Using Compass or MongoDB Shell it works