rajagopalanr has asked for the wisdom of the Perl Monks concerning the following question:

I am writing a Perl script to search elasticsearch index. My text contains special characters \ and :. i try to filter them with \ and then search with the formatted string. But Perl again escapes them with one \ and post it them to elasticsearch. for eg if the text is C_:\_20Label_ and i escape them in code as C_\:\\_20Label, perl escapes again as C_\\:\\\\_20Label_. How to fix this issue.

  • Comment on Problem with escape sequence when working with elasticsearch

Replies are listed 'Best First'.
Re: Problem with escape sequence when working with elasticsearch
by Corion (Patriarch) on Jan 30, 2018 at 07:48 UTC

    Where in your code does Perl escape this? What module are you using to talk to Elasticsearch?

    If you are inspecting your data via Data::Dumper, that one will add an additional layer of escaping as it outputs data as Perl syntax.

    Please show us a short, self-contained example that shows where Perl is doing additional escaping when sending data to Elasticsearch.

    In my usage of Search::ElasticSearch I had no need to escape anything. If you want index a cleaned up version of your text, maybe you want to use the functions of Elasticsearch to clean up your text in the index but keep the document as is?