Skip to content

Instantly share code, notes, and snippets.

@tacryt-socryp
Created March 2, 2021 17:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tacryt-socryp/49bcffb2860c45771dfc4e10b9fc5d37 to your computer and use it in GitHub Desktop.
Save tacryt-socryp/49bcffb2860c45771dfc4e10b9fc5d37 to your computer and use it in GitHub Desktop.
Graph store naive full-text string search
/- spider
/+ strandio, store=graph-store, graph
=, strand=strand:spider
^- thread:spider
|= arg=vase
=/ m (strand:spider ,vase)
^- form:m
=+ !<([~ qry=tape] arg)
~& > "searching all graphs"
=* orm orm:store
;< k-upd=update:store bind:m
%+ scry:strandio ,update:store
/gx/graph-store/keys/noun
?> ?=(%0 -.k-upd)
?> ?=(%keys -.q.k-upd)
=/ keys=(list resource:store) ~(tap in resources.q.k-upd)
=| results=(list [index:store node:store])
|-
=* loop $
?~ keys
~& (lent results)
(pure:m !>(results))
~& searching+i.keys
;< g-upd=update:store bind:m
%+ scry:strandio ,update:store
/gx/graph-store/graph/(scot %p entity.i.keys)/[name.i.keys]/noun
?> ?=(%0 -.g-upd)
?> ?=(%add-graph -.q.g-upd)
=. results
%+ weld
results
^- (list [index:store node:store])
%+ skim (tap-deep:graph ~ graph.q.g-upd)
|= [k=* v=node:store]
^- ?
%+ roll contents.post.v
|= [c=content:store found=_|]
?. ?=(%text -.c)
found
=/ index (find qry (trip text.c))
?=(^ index)
loop(keys t.keys)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment