Beispiel #1
0
 async def query(tx):
     query = [
         [var("blog"), "title", "hyper.dev"],
         [var("post"), "blog", var("blog")],
         [var("post"), "title", var("title")],
     ]
     out = await aiolist(nstore.query(tx, ntest, *query))
     return out
async def _keywords_to_token(tx, tokens, keyword):
    query = nstore.select(tx, tokens, keyword, nstore.var('uid'))
    try:
        uid = await query.__anext__()
    except StopAsyncIteration:
        return None
    else:
        uid = uid['uid']
        return uid
async def index(tx, store, docuid, counter):
    # translate keys that are string tokens, into uuid4 bytes with
    # store.tokens
    tokens = dict()
    for string, count in counter.items():
        query = nstore.select(tx, store.tokens, string, nstore.var('uid'))
        try:
            uid = await query.__anext__()
        except StopAsyncIteration:
            uid = uuid4()
            nstore.add(tx, store.tokens, string, uid)
        else:
            uid = uid['uid']
        tokens[uid] = count

    # store tokens to use later during search for filtering
    found.set(tx, found.pack((store.prefix_counters, docuid)),
              zstd.compress(found.pack(tuple(tokens.items()))))

    # store tokens keys for candidate selection
    for token in tokens:
        found.set(tx, found.pack((store.prefix_index, token, docuid)), b'')
Beispiel #4
0
 async def query(tx):
     query = nstore.select(tx, ntest, var("blog"), "title", "hyper.dev")
     query = nstore.where(tx, ntest, query, var("post"), "blog", var("blog"))
     out = await aiolist(nstore.where(tx, ntest, query, var("post"), "title", var("title")))
     return out
Beispiel #5
0
 async def query(tx):
     out = await aiolist(nstore.select(tx, ntest, hyperdev, "title", var("title")))
     return out
Beispiel #6
0
 async def query(tx):
     out = await aiolist(nstore.select(tx, ntest, copernic, var("key"), var("value")))
     return out
Beispiel #7
0
 async def query(tx):
     out = await aiolist(nstore.select(tx, ntest, var("subject"), "keyword", "corporate"))
     return out
Beispiel #8
0
 async def query(tx):
     seed = nstore.select(tx, ntest, var("identifier"), "keyword", "hacker")
     out = await aiolist(nstore.where(
         tx, ntest, seed, var("identifier"), "title", var("blog")
     ))
     return out
Beispiel #9
0
 async def query(tx):
     out = await aiolist(nstore.select(tx, ntest, var("subject"), "title", "hyper.dev"))
     return out