Datastore Tag Search Solution

I have millions of items ordered in advance. Each element has many logical attributes. Let him say that there are only about ten thousand possible attributes, each of which has a dozen of them.

I would like to be able to query in real time (a few milliseconds) the top n elements given ~ by any combination of attributes.

Which solution would you recommend? I am looking for something extremely scalable.

- Page - We are currently looking at the mongodb index and array, do you see any limitations?
- SolR is a possible solution, but we do not need text search capabilities.

+5
source share
3 answers

Mongodb , , ,

{ score:2131, attributes: ["attr1", "attr2", "attr3"], ... }

, att1 attr2

c = db.mycol.find({ attributes: { $all: [ "attr1", "attr2" ] } })

c = db.mycol.find({ attributes: { $all: [ "attr1", "attr4" ] } })

, , , , :

c = db.mycol.find({ attributes: { $all: [ "attr1", "attr2" ] }}).sort({score:1})

, , .

db.mycol.ensureIndex({attributes:1, score:1})

db.mycol.find({ attributes: { $all: [ "attr1" ] }}).explain()

Mongo , , .

+9

, . , . :

[
    {
        true_tags:[attr1, attr2, attr3, ...],
        false_tags: [attr4, attr5, attr6, ...]
    },
]

true_tags false_tags. $in, $all,... query.

+2

Redis

  • " n " " , "

Redis , : Sorted Set = > . , , ZRANGEBYSCORE:

ZRANGEBYSCORE key min max [WITHSCORES] [LIMIT offset count]

Sorted Set commands Redis, ( ) . , , , Set.


As for MongoDB, since you mentioned millions, if you cannot bend incremental queries to work on your problem, I would not expect a second answer.

As @nickdos Solr Relevancy mentioned is a pretty powerful feature, but the number of attributes will be a problem, since for each element you need to store all these attributes in memory. Although a dozen for each may not be so bad => just try and see.

+2
source

All Articles