zoukankan      html  css  js  c++  java
  • solr和mongodb比较

    solr非常灵活,虽然mongodb添加索引查询速度比较快,但是solr查询比mongodb更加灵活,所以需要获取mongodb的oplog,实时将oplog中的数据推送到solr中

    oplog

    A capped collection that stores an ordered history of logical writes to a MongoDB database. The oplog is the basic mechanism enabling replication in MongoDB. See Replica Set Oplog.

    tailable cursor  是capped collection的一个特性。

    mongodb 的oplog的参数解释在官网很难找到。

    ts: the time this operation occurred.
    h: a unique ID for this operation. Each operation will have a different value in this field.
    op: the write operation that should be applied to the slave. n indicates a no-op, this is just an informational message.
    ns: the database and collection affected by this operation. Since this is a no-op, this field is left blank.
    o: the actual document representing the op. Since this is a no-op, this field is pretty useless.
    The o field now contains the document to insert or the criteria to update and remove. Notice that, for the update, there are two o fields (o and o2). o2 give the update criteria and o gives the modifications (equivalent to update()‘s second argument).
    ts:8字节的时间戳,由4字节unix timestamp + 4字节自增计数表示。
    这个值很重要,在选举(如master宕机时)新primary时,会选择ts最大的那个secondary作为新primary。
    op:1字节的操作类型,例如i表示insert,d表示delete。
    ns:操作所在的namespace。
    o:操作所对应的document,即当前操作的内容(比如更新操作时要更新的的字段和值)
    o2: 在执行更新操作时的条件,仅限于update时才有该属性。
    其中op,可以是如下几种情形之一:
    “i”: insert
    “u”: update
    “d”: delete
    “c”: db cmd
    “db”:声明当前数据库 (其中ns 被设置成为=>数据库名称+ ‘.’)
    “n”: no op,即空操作,其会定期执行以确保时效性 。

  • 相关阅读:
    Luogu6300 悔改 [FFT,阈值法]
    CF1016G Appropriate Team [Pollard-rho,FMT]
    AGC021F Trinity【计数,NTT】
    CF578F Mirror Box 【图论,Matrix-Tree】
    [ARC083]Collecting Balls
    HNCPC2019部分题解
    [LuoguP1829]Crash的文明表格(二次扫描与换根+第二类斯特林数)
    [CF960G]Bandit Blues(第一类斯特林数+分治卷积)
    [CF804F]Fake bullions
    [CF643E]Bear and Destroying Subtrees(期望,忽略误差)
  • 原文地址:https://www.cnblogs.com/usual2013blog/p/3957502.html
Copyright © 2011-2022 走看看