Sha256: e5d5f9944657ac83c607f63b146e8399ae27eff1ef4f4743a031593d0af3cd55

Contents?: true

Size: 456 Bytes

Versions: 1

Compression:

Stored size: 456 Bytes

Contents

# encoding: utf-8
require "logstash/filters/utils"

class BingQueryParser

  public
  def initialize
    @re_url = /(?:www\.)?bing\..*/
    @re_query = /^\/search\?(?:[^&]*&)?q=(?<query>[^&#]*)/i
  end

  public
  def match(siteName)
    return @re_url.match(siteName)
  end

  def parse(query)
    query = Utils.removeInvalidChars(query)
    m = @re_query.match(query)
    if m then
      return m["query"].tr("+", " ").split.join(" ")
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
logstash-filter-search-engine-2.0.0 lib/logstash/filters/parsers/bing.rb