Query in a MongoDB Map Reduce Function

后端 未结 2 820
北海茫月
北海茫月 2020-12-21 20:04

I have streamed and saved about 250k tweets into MongoDB and here, I am retrieving it, as you can see, based on a word, or keyword, present in the tweet.

Mon         


        
2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-21 20:34

    Although you already accepted the answer by Kay and this one will likely be ignored, I would like to suggest an alternative solution.

    Th MongoDB documentation has an article about how to perform full text search in Mongo. In order to allow text-based fields to be searched quickly for individual words, they suggest to prepare the documents by splitting the textfields into arrays of individual words, store these arrays in the documents together with the full text, and create an index over this array.

    Afterwards you can very quickly find all documents which contain a specific word, because your search query can 1. use an index and 2. doesn't have to use a regular expression (which can be very expensive).

提交回复
热议问题