Module: Elasticsearch::API::Response::Helpers::StringHelper
- Included in:
- ExplainParser
- Defined in:
- lib/elasticsearch/api/response/helpers/string_helper.rb
Constant Summary collapse
- WORD =
/[\w\.\*]+/- WITH_QUOTE =
/"[^"]*"/- WITH_BRACKET =
/\[[^\]]*\]/- QUOTE_TOKENIZER =
/(?:(?<field>#{WORD})(\:(?<value>(#{WORD}|#{WITH_QUOTE}|#{WITH_BRACKET})))?)+/
Instance Method Summary collapse
-
#tokenize_contents(string) ⇒ Hash
Field name as a key and values as a value.
Instance Method Details
#tokenize_contents(string) ⇒ Hash
Returns field name as a key and values as a value.
12 13 14 15 16 17 18 |
# File 'lib/elasticsearch/api/response/helpers/string_helper.rb', line 12 def tokenize_contents(string) string .scan(QUOTE_TOKENIZER) .each_with_object(Hash.new{|h,k| h[k] = []}) { |(field, value), memo| memo[field] << value } end |