twitter icon indicating copy to clipboard operation
twitter copied to clipboard

Result list by 'text' field

Open ayxos opened this issue 10 years ago • 1 comments

Hi again, im a Redis newbie, i need a list with every single tweet with the same 'text'

ex. every single tweet (it doesnt matter from who) with the text "Welcome"

Any help? thank you so much

ayxos avatar Nov 17 '15 10:11 ayxos

Hey, I think if you only need a simple solution, you can just iterate all tweets and see if the text matches the specific term. As you may know this should work only if the data set is small enough because its time complexity is O(n).

If you need more faster solution, you probably need to construct index. I just found a post on Stack Overflow which could be related to this topic. The basic idea is to create the separated space in Redis using Set (or Sorted Set) data structure to store the term as key and the list of tweet IDs as value.

term:welcome => [123, 465, 987]
term:foo => [1024]
term:bar => [2048]

In the example above, each terms ("welcom", "foo" and "bar") are used as a key of Set and values (123, 465, 987, 1024 and 2048) are the list of tweet IDs which contain the term in its tweet. This is pretty much same implementation as most search engines do for their full text search functionality.

I hope this will help to solve your problem.

tatsuya avatar Nov 17 '15 11:11 tatsuya