Created
March 2, 2021 17:52
-
-
Save tacryt-socryp/49bcffb2860c45771dfc4e10b9fc5d37 to your computer and use it in GitHub Desktop.
Graph store naive full-text string search
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/- 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