I would think this is a common issue, but I've not been able to find a solution. I am trying to index an item that has an apostrophe (single-quote) character in it. When I execute cURL from the command line, I'm thrown into the cURL interactive mode. I figured I'd just escape the apostrophe ('), but that made no difference. Here is my test:
On Mon, 2011-01-03 at 13:19 -0800, searchersteve wrote:
I would think this is a common issue, but I've not been able to find a
solution. I am trying to index an item that has an apostrophe (single-quote)
character in it. When I execute cURL from the command line, I'm thrown into
the cURL interactive mode. I figured I'd just escape the apostrophe ('),
but that made no difference. Here is my test:
Thanks, Clint! That worked. I am using an older version of PHP that lacks json_encode, so I used a class called Services_JSON instead. The json_encode function for PHP5+ includes an option to convert the ' character.
If I am opening my indexed data from ES as an API, what do I need to tell developers about expecting the \u0027 ?
Separately, if this is a standard issue with injecting JSON into ES, should it maybe be part of the documentation?
Steve
On Mon, 2011-01-03 at 13:19 -0800, searchersteve wrote:
> I would think this is a common issue, but I've not been able to find a
> solution. I am trying to index an item that has an apostrophe (single-quote)
> character in it. When I execute cURL from the command line, I'm thrown into
> the cURL interactive mode. I figured I'd just escape the apostrophe (\'),
> but that made no difference. Here is my test:
On Tue, 2011-01-04 at 11:38 -0800, searchersteve wrote:
Thanks, Clint! That worked. I am using an older version of PHP that lacks
json_encode, so I used a class called Services_JSON instead. The json_encode
function for PHP5+ includes an option to convert the ' character.
If I am opening my indexed data from ES as an API, what do I need to tell
developers about expecting the \u0027 ?
Separately, if this is a standard issue with injecting JSON into ES, should
it maybe be part of the documentation?
\u0027 is just a form of UTF-8 encoding that JSON understands. So any
(compliant) JSON decoder will handle it just fine.
Normally, using any of the ES APIs (Java, Perl, Python, Ruby, JS etc)
you wouldn't need to encode the ' but when using it with curl on the
command line, you're having to account for the shell's own
quoting/escaping - that's where the problem is.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.