Storing path data in a field?

I would like to store file path data in a document. The example document structure is
{
"hostname" : "socbm331",
"path" : "/opt/sicl/bin/iproc",
"type" : "f",
"user" : "bin",
"group" : "bin",
"size" : 21871
}

I would like to search the documents by path value.
The search for

http://localhost:9200/rspec_filesystem_snapshots/_search?q=path.keyword:%2Fopt%2Fsicl%2Fbin%2Fiproc&pretty

gives me a load of documents with path value which do not match, like:
{ "hostname" : "socbm331", "path" : "/opt/sicl/share/man/man8/iproc.8", "type" : "f", "user" : "bin", "group" : "bin", "size" : 2077 }

How to accomplish this with version 5.4 ?

Did you ever find a resolution for this? I would like to do this as well.

My current temporary workaround is to encode and store path_base64 but it doesn't fix the problem.

Would you be able to show me the code about how to encode and store path_base64?

Sure, I'm retrieving data with ruby, here is a snippet of the transformation

def transform_entries_to_jdl(index_name = 'filesystem_snapshot_entries', marker = nil)

time = @timestamp
if @timestamp.class == 'String'
  time = Time.parse(@timestamp)
end

jdl = []
@entries.each do |entry|
  path = URI.escape(entry['path'])

  path_base64 = Base64.encode64(entry['path']).strip().gsub(/\n/, '')
  content = {:type => entry['type'], :user => entry['user'], :group => entry['group'], :size => entry['size'], :permissions => entry['permissions'], timestamp: time}
  value = {:hostname => hostname, :path =>  path, :path_base64 =>  path_base64, :type => entry['type'], :user => entry['user'], :group => entry['group'], :size => entry['size'], :permissions => entry['permissions'], timestamp: time, :configuration_checksum => Digest::MD5.hexdigest(content.to_s), :marker => marker}
  value_to_insert = {index: {_index: index_name, _type: 'filesystem_snapshot_entry',  data: value}}
  jdl << value_to_insert
end

return jdl
end

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.