0

I would like to manually serialize an object to a string and index it by using PlainElastic.net. I tried the followed:

Disk myDisk = Disks[1]; // Gets a Disk object from a dictionary

string command = Commands.Index("Album", "Music", myDisk.Id.ToString());
string json = "\"query\":{\"disk\": {\"album_id\":\"" + myDisk.albumId + "\",\"disk_id\":\"" + myDisk.Id + "\"}}";
OperationResult response = connection.Put(command, json);

However, I get an exception:

"The remote server returned an error: (400) Bad Request." Afterwards, I get the following exception: {"error":"MapperParsingException[Malformed content, must start with an object]","status":400}

Does anyone know how I should perform the indexing manually?

Thank you in advance.

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Gilad
  • 43
  • 8
  • By the way, If you can suggest indexing using rest api and not through plainelastic.net, it is more than great :) However, I still need to write the index manually as I would like to index an object selected from my DB. 10x! – Gilad Oct 21 '13 at 13:23
  • 1
    Your json is not valid. As the error says, it should start with an object - you're missing the start object '{' in the beginning of the JSON string. and plainelastic uses the REST API. It's just a wrapper working against it. – Rotem Hermon Oct 21 '13 at 13:42
  • Hi Rotem, first thank you! I fixed the Json and it worked. I know that the plainelastic is a wrapper which uses the rest api. What I meant is to replace the plainelastic.net usage with direct rest api calls. Anyway, thank you! it worked :) – Gilad Oct 21 '13 at 13:46
  • You can issue the REST calls as just plain web requests, but I don't see a reason to do this - plainelastic is quite a nice library for that. – Rotem Hermon Oct 21 '13 at 13:51

0 Answers0