Example #1
0
def update_via_scheme(items):
    db = get_db()
    schemes = dict()
    upd_index_docs = []
    for item in items:
        if "scheme" in item:
            if item["scheme"] not in schemes:
                scheme = db.contribs.scheme.find_one({"_id": item["scheme"]})
                schemes[item["scheme"]] = scheme
            else:
                scheme = schemes[item["scheme"]]
            del scheme["_id"]
            upd_index_docs +=  item_2_index_docs(item, scheme)
    upd_index_docs = utils_array.unique(upd_index_docs, lambda x: x[2])
    es.bset(upd_index_docs)
Example #2
0
def update_via_scheme(items):
    db = get_db()
    schemes = dict()
    upd_index_docs = []
    for item in items:
        if "scheme" in item:
            if item["scheme"] not in schemes:
                scheme = db.contribs.scheme.find_one({"_id": item["scheme"]})
                schemes[item["scheme"]] = scheme
            else:
                scheme = schemes[item["scheme"]]
            del scheme["_id"]
            upd_index_docs += item_2_index_docs(item, scheme)
    upd_index_docs = utils_array.unique(upd_index_docs, lambda x: x[2])
    es.bset(upd_index_docs)
Example #3
0
def convert():
    db = get_db()
    user = db.users.find_one({"_id": "twitter@baio1980"})
    names = []
    tags = []
    for c in user["contribs"]:
        contrib = db.contribs_v2.find_one({"_id": ObjectId(c["ref"])})
        if contrib and "items" in contrib:
            for i in contrib["items"]:
                n = i["object"]
                names.append(n)
                n = i["subject"]
                names.append(n)
                tags += i["predicates"]
    names = map(lambda x: (x, x), set(names))
    tags = unique(tags, lambda x: x["type"] + "_" + x["val"])
    tags = map(lambda x: ("relations.ru", x["type"], x["val"], {"val": x["val"]}), tags)
    es.mset("person-names.ru", "politic-rus", names)
    es.bset(tags)
Example #4
0
def convert():
    db = get_db()
    user = db.users.find_one({"_id": "twitter@baio1980"})
    names = []
    tags = []
    for c in user["contribs"]:
        contrib = db.contribs_v2.find_one({"_id": ObjectId(c["ref"])})
        if contrib and "items" in contrib:
            for i in contrib["items"]:
                n = i["object"]
                names.append(n)
                n = i["subject"]
                names.append(n)
                tags += i["predicates"]
    names = map(lambda x: (x, x), set(names))
    tags = unique(tags, lambda x: x["type"] + "_" + x["val"])
    tags = map(
        lambda x: ("relations.ru", x["type"], x["val"], {
            "val": x["val"]
        }), tags)
    es.mset("person-names.ru", "politic-rus", names)
    es.bset(tags)