[erlang-questions] erlang-questions Digest, Vol 20, Issue 49
Jacob Perkins
japerk@REDACTED
Tue Jan 20 00:39:23 CET 2009
> The site I'm working on needs to display images that area searchable by
> using keywords (for example something like Cats AND Dogs...). Do you have
> any suggestions or know how one can do so in erlang? For example, lets say
> before uploading the image I attach a bunch of key words to it, lets say in
> the following manner
> {[Keyword1...Keywordn],Image}
Like Christian said, you need an inverted index, where each keywords points
to a list of image ids. How you do it really depends on the number of
keywords and images you are dealing with. Here's two suggestions.
1) Simple set table with tuples like
{keyword, [image_id]}
2) Ordered set table with tuples like
{{keyword, image_id}, value}
The benefit of #2 is that every record is very small so it can work with a
large number of image_ids, and since the table is an ordered_set, you can
quickly get all the image_ids for a single keyword. The extra value can be
whatever you want: metadata, score/importance, whatever.
Once you have a list for each keyword, you can do a set intersection.
Here's some wikipedia articles with deeper info.
http://en.wikipedia.org/wiki/Index_(search_engine)
http://en.wikipedia.org/wiki/Information_retrieval
Jacob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090119/1f0f2d44/attachment.htm>
More information about the erlang-questions
mailing list