Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing language is not saved #70

Open
Dravere opened this issue Aug 3, 2024 · 9 comments
Open

Changing language is not saved #70

Dravere opened this issue Aug 3, 2024 · 9 comments

Comments

@Dravere
Copy link

Dravere commented Aug 3, 2024

When I try to change the language in the admin plugin panel, the language is not saved. This seems to happen because an error occurs during reindexing at:

await searchModule.changeIndexLanguage(convertLanguageName(language));

It thus never reaches the second line and never saves the language. Though looking at the Mongo process it seems the indexing is continuing and thus working.

The error I get back:
dbsearch-language-change-error

I'm trying to change the language from english to german.

@barisusakli
Copy link
Owner

When you restart nodebb it should call createIndices here https://github.com/barisusakli/nodebb-plugin-dbsearch/blob/master/lib/mongo.js#L7-L18, and create that index is that not happening?

@Dravere
Copy link
Author

Dravere commented Aug 3, 2024

I think it creates the index, but not in de. It always uses en, since it is not stored in the database, which language should be used. The property indexLanguage in the plugin config is never set.

@barisusakli
Copy link
Owner

What do you get when you run db.searchchat.getIndexes() in mongodb ?

@Dravere
Copy link
Author

Dravere commented Aug 3, 2024

Result: [ { v: 2, key: { _id: 1 }, name: '_id_' } ]

@barisusakli
Copy link
Owner

Yeah so it looks like the indexes are not created for that collection. This is what it looks like when it works.

> db.searchchat.getIndexes()
[
        {
                "v" : 2,
                "key" : {
                        "_id" : 1
                },
                "name" : "_id_"
        },
        {
                "v" : 2,
                "key" : {
                        "_fts" : "text",
                        "_ftsx" : 1,
                        "roomId" : 1,
                        "uid" : 1
                },
                "name" : "content_text_roomId_1_uid_1",
                "background" : true,
                "weights" : {
                        "content" : 1
                },
                "default_language" : "english",
                "language_override" : "language",
                "textIndexVersion" : 3
        }
]

@barisusakli
Copy link
Owner

You can try manually creating it with.

db.searchchat.createIndex({ content: 'text', roomId: 1, uid: 1 }, { background: true });

Once that's done try changing language in acp.

@Dravere
Copy link
Author

Dravere commented Aug 3, 2024

Ok, that did work. But why did I need this manual step?

@barisusakli
Copy link
Owner

I am not sure, it should happen on nodebb start here check if that line is executed when you restart nodebb, it doesn't get executed if you have jobsDisabled in config for example.

@Dravere
Copy link
Author

Dravere commented Aug 3, 2024

Well, I dropped the index via mongosh, restarted NodeBB and it created the index again as it should. But there is one difference now, the indexLanguage property in the plugin config is set.

So I tried it again, but unset the indexLanguage property in the plugin config before restarting NodeBB. This time there is an error during the startup:

error: [plugins] Error executing 'static:app.load' in plugin 'nodebb-plugin-dbsearch'
MongoServerError: An equivalent index already exists with the same name but different options. Requested index: { v: 2, key: { _fts: "text", _ftsx: 1, uid: 1, cid: 1 }, name: "content_text_uid_1_cid_1", background: true, weights: { content: 1 }, default_language: "english", language_override: "language", textIndexVersion: 3 }, existing index: { v: 2, key: { _fts: "text", _ftsx: 1, uid: 1, cid: 1 }, name: "content_text_uid_1_cid_1", background: true, default_language: "de", weights: { content: 1 }, language_override: "language", textIndexVersion: 3 }
    at Connection.sendCommand (/home/dravere/Projects/cppnet/nodebb/node_modules/mongodb/lib/cmap/connection.js:297:27)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Connection.command (/home/dravere/Projects/cppnet/nodebb/node_modules/mongodb/lib/cmap/connection.js:325:26)
    at async Server.command (/home/dravere/Projects/cppnet/nodebb/node_modules/mongodb/lib/sdam/server.js:166:24)
    at async CreateIndexesOperation.executeCommand (/home/dravere/Projects/cppnet/nodebb/node_modules/mongodb/lib/operations/command.js:74:16)
    at async CreateIndexesOperation.execute (/home/dravere/Projects/cppnet/nodebb/node_modules/mongodb/lib/operations/indexes.js:121:9)
    at async executeOperation (/home/dravere/Projects/cppnet/nodebb/node_modules/mongodb/lib/operations/execute_operation.js:112:20)
    at async Collection.createIndex (/home/dravere/Projects/cppnet/nodebb/node_modules/mongodb/lib/collection.js:327:25)
    at async exports.createIndices (/home/dravere/Projects/cppnet/nodebb/node_modules/nodebb-plugin-dbsearch/lib/mongo.js:14:3)
    at async search.init [as method] (/home/dravere/Projects/cppnet/nodebb/node_modules/nodebb-plugin-dbsearch/lib/dbsearch.js:71:2)

And the index is not created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants