Home > database >  Consult a great god, and how data should be stored in the mongo good?
Consult a great god, and how data should be stored in the mongo good?

Time:09-18

data structures:
Term 1: {article 1 id: weight value of 0.2, article 2 of the id: weight value of 0.5}
Term 2: {article 1 id: weight value of 0.4, article 3 of the id: weight value of 0.1}
.
(there are a lot of words, around 100000)
.


final query:
(parallel real-time query)Such as: according to a set of words, words 1, 2], query the highest weight value that an article id, above is the article 1 (0.2 + 0.4=0.6) largest


Problem: as the top of the structure of the data should be in the form of how to save in directing to the query efficiency is the highest??????

If put all the words are stored in a document, should be more than 16 m size, query better late if multiple documents preservation, very convenient and quite a few


CodePudding user response:

In the words family key (_id: 'word_name)
Words in the corresponding article name on the list,

{_id: 'word_name' score: [{article: 1, the score: 0.2}, {article: 2, score: 0.5}]}

# can field to establish an index in each of the words:
CreateIndex ({" score. The article ": 1})

CodePudding user response:

I also in the selected file server, don't know what's right

CodePudding user response:

This kind of situation index should be without
  • Related