I'm looking for a Java/Scala library that can take an user query and a text and returns if there was a matching or not.
I'm processing a stream of information, ie: Twitter Stream, and can't afford to use a batching process, I need to evaluate each tweet in realtime, instead of index it through Lucene RAMDisk and querying it later.
It's possible create a parser/lexer using ANTLR but this is such common usage that I can't believe nobody create a lib before.
Some samples from TextQuery Ruby library that does exactly what I need:
TextQuery.new("'to be' OR NOT 'to_be'").match?("to be") # => true
TextQuery.new("-test").match?("some string of text") # => true
TextQuery.new("NOT test").match?("some string of text") # => true
TextQuery.new("a AND b").match?("b a") # => true
TextQuery.new("a AND b").match?("a c") # => false
q = TextQuery.new("a AND (b AND NOT (c OR d))")
q.match?("d a b") # => false
q.match?("b") # => false
q.match?("a b cdefg") # => true
TextQuery.new("a~").match?("adf") # => true
TextQuery.new("~a").match?("dfa") # => true
TextQuery.new("~a~").match?("daf") # => true
TextQuery.new("2~a~1").match?("edaf") # => true
TextQuery.new("2~a~2").match?("edaf") # => false
TextQuery.new("a", :ignorecase => true).match?("A b cD") # => true
Once it was implemented in Ruby it's not suitable for my platform, also I can't use JRuby just for this point on our solution:
I found a similar question but couldn't get answer from it: Boolean Query / Expression to a Concrete syntax tree
Thanks!