Is there a way to mimic the _source path for _search in a specific document?

The resource /users/1/_source will return data WITHOUT ANY METADATA, like:

{
   "id" : 1,
   "name" : "John"
}

There is a way to get an array of sources WITHOUT ANY METADATA if a search is submitted to a specific document (e.g., /users/_search )? The expected result will be something like:

[
   {
       "id" : 1,
       "name" : "John"
   },
   {
       "id" : 2,
       "name" : "Mark"
   },
   {
       "id" : 3,
       "name" : "Ana" 
   }
]

Thanks in advance.

Like this plugin?

Hi, Jörg.

Exactly. I tried to use your plugin in ES 2.1, but got this error:

ERROR: Could not find plugin descriptor 'plugin-descriptor.properties' in plugin zip

But I was wondering if there is a way to do that in ES 2.1 directly. I've checked many old threads about this subject, so I just want to be sure that this still isn't possible for 2.1 before I go to other directions.

Thanks for your answer.

It is possible to use the arrayformat plugin with the JAVA API for ES or I will have to use plain Java networking to do that?

Thanks in advance.

I have to upgrade the plugin to ES 2.1.

It's HTTP, no Java API.

With Java, you can iterate through the hits, the "metadata problem" does not exist.

My question wasn't good, probably because my english isn't good. :slight_smile:

Currently I'm using the ES Java API to make HTTP requests to ES (e.g. a _search endpoint in some document). I was wondering if could be possible use your plugin with the ES JAVA API. Something like this: https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-search.html

But I think I will have to write plain Java requests (without the ES Java API) to use your plugin, because client.prepareSearch(...) will result in a HTTP _search.

Thanks.

Your english is good, I understand, at least I hope so :smile:

Java is not using HTTP _search, it uses transport protocol (native Elasticsearch node-to-node protocol) over port 9300.

With Java search API, you get a SearchResponse object. From there you can iterate through the search hits. Therefore, you can see hits as an array. No metadata like _index, _type, _id are in the way, like in JSON hits, which are transported over HTTP API.

I didn't know that, I'm new to ElasticSearch world. Thanks!