Created
September 9, 2011 11:48
-
-
Save wardbekker/1206014 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
query_results({docs, Documents}, [Ws]) -> | |
%% create a nice list of results with scores. | |
Ws:send(["got doc results"]), | |
Partial = "<li><strong>Id:</strong> ~p<br /> | |
<strong>Score:</strong> ~p<br /> | |
<strong>Title:</strong> ~ts<br /> | |
<strong>Body:</strong> ~ts</li>", | |
Html = lists:map( | |
fun({Score, Attributes}) -> | |
io_lib:format( | |
Partial, | |
[dict:fetch("Id", Attributes), | |
Score, | |
dict:fetch("Title", Attributes), | |
dict:fetch("Body", Attributes) | |
]) | |
end, | |
Documents | |
), | |
Output = io_lib:format("<p><ol>~ts</ol></p>", [lists:append(Html)]), | |
Ws:send(["documents:", unicode:characters_to_binary(Output)]), | |
ok; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment