I
I
ikerya2020-05-23 13:00:46
MongoDB
ikerya, 2020-05-23 13:00:46

How to ensure the uniqueness of definitions, provided that the query is auto-corrected by an online dictionary?

Hello. I have a collection of definitions -- Definition. There is a script that implements the search for definitions of an English word in an online dictionary.

The problem is the uniqueness of the definitions. There can be several definitions for one word, so the uniqueness of the title cannot be guaranteed, since only the first definition will "crawl through", and the rest will be ignored.

At the very beginning of the search, I make a selection by title, whether there are definitions in the database for such and such a request. The problem is that they can "skip" a couple of requests with the same title, receiving a response that there are no definitions for this title yet (since the first request has not yet been processed and has not added a definition) and the code will continue executing. And thus two identical definitions with the same title can be added to the database.

The definition text itself is stored in the definition field. Tell me, would it be reasonable to create a text index on this field, and if so, how can this be done better?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question