Get all *STORED* fields from a query

Hi all,

First, i'm a beginner with ES, so .. be kind (though i've a strong
background with Lucene).

I'm trying to get all the stored fields (with a mapping) in my seach.
These
stored fields seems to be stored alright, thic code:

   SearchResponse rsp = getClient().prepareSearch(INDEX_SKIMM)
           .setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
           .setQuery(q)
           .addField("firstname")
           .setFrom(startIndex)
           .setSize(limit > MAX_RESULTS ? MAX_RESULTS : limit )
           .setExplain(true)
           .execute()
           .actionGet();

returns me the 'firstname' field in my SearchHit;

But, if i remove the
.addField("firstname")
line, i do not get ANY of my stored fields.

Is it normal ?

I've found a (ugly) workaround by adding this line in the search:
.addField("*")

and i gain access to all stored fields.

Thanks in advance for your answers !

I assume that when you don't specify any field, and you get nothing back,
is because you disabled the _source field. If you want ot get all the
stored fields, then yes, you need to do: addField("*"), why is this ugly?

Btw, most times, going each field specifically stored is wrong, and _source
should be used.

On Thu, Nov 24, 2011 at 2:04 AM, ikarius frederic.vergez@gmail.com wrote:

Hi all,

First, i'm a beginner with ES, so .. be kind (though i've a strong
background with Lucene).

I'm trying to get all the stored fields (with a mapping) in my seach.
These
stored fields seems to be stored alright, thic code:

  SearchResponse rsp = getClient().prepareSearch(INDEX_SKIMM)
          .setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
          .setQuery(q)
          .addField("firstname")
          .setFrom(startIndex)
          .setSize(limit > MAX_RESULTS ? MAX_RESULTS : limit )
          .setExplain(true)
          .execute()
          .actionGet();

returns me the 'firstname' field in my SearchHit;

But, if i remove the
.addField("firstname")
line, i do not get ANY of my stored fields.

Is it normal ?

I've found a (ugly) workaround by adding this line in the search:
.addField("*")

and i gain access to all stored fields.

Thanks in advance for your answers !

Thank you for your fast answer, will try _source ASAP !

On 24 nov, 14:52, Shay Banon kim...@gmail.com wrote:

I assume that when you don't specify any field, and you get nothing back,
is because you disabled the _source field. If you want ot get all the
stored fields, then yes, you need to do: addField("*"), why is this ugly?

Btw, most times, going each field specifically stored is wrong, and _source
should be used.

On Thu, Nov 24, 2011 at 2:04 AM, ikarius frederic.ver...@gmail.com wrote:

Hi all,

First, i'm a beginner with ES, so .. be kind (though i've a strong
background with Lucene).

I'm trying to get all the stored fields (with a mapping) in my seach.
These
stored fields seems to be stored alright, thic code:

  SearchResponse rsp = getClient().prepareSearch(INDEX_SKIMM)
          .setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
          .setQuery(q)
          .addField("firstname")
          .setFrom(startIndex)
          .setSize(limit > MAX_RESULTS ? MAX_RESULTS : limit )
          .setExplain(true)
          .execute()
          .actionGet();

returns me the 'firstname' field in my SearchHit;

But, if i remove the
.addField("firstname")
line, i do not get ANY of my stored fields.

Is it normal ?

I've found a (ugly) workaround by adding this line in the search:
.addField("*")

and i gain access to all stored fields.

Thanks in advance for your answers !

Well ugly was a bit too much. But is this option documented ?
I tried this "at random" and it worked.

On 24 nov, 14:52, Shay Banon kim...@gmail.com wrote:

I assume that when you don't specify any field, and you get nothing back,
is because you disabled the _source field. If you want ot get all the
stored fields, then yes, you need to do: addField("*"), why is this ugly?

Btw, most times, going each field specifically stored is wrong, and _source
should be used.

On Thu, Nov 24, 2011 at 2:04 AM, ikarius frederic.ver...@gmail.com wrote:

Hi all,

First, i'm a beginner with ES, so .. be kind (though i've a strong
background with Lucene).

I'm trying to get all the stored fields (with a mapping) in my seach.
These
stored fields seems to be stored alright, thic code:

  SearchResponse rsp = getClient().prepareSearch(INDEX_SKIMM)
          .setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
          .setQuery(q)
          .addField("firstname")
          .setFrom(startIndex)
          .setSize(limit > MAX_RESULTS ? MAX_RESULTS : limit )
          .setExplain(true)
          .execute()
          .actionGet();

returns me the 'firstname' field in my SearchHit;

But, if i remove the
.addField("firstname")
line, i do not get ANY of my stored fields.

Is it normal ?

I've found a (ugly) workaround by adding this line in the search:
.addField("*")

and i gain access to all stored fields.

Thanks in advance for your answers !

Yea, its documented:
Elasticsearch Platform — Find real-time answers at scale | Elastic.

On Thu, Nov 24, 2011 at 7:12 PM, ikarius frederic.vergez@gmail.com wrote:

Well ugly was a bit too much. But is this option documented ?
I tried this "at random" and it worked.

On 24 nov, 14:52, Shay Banon kim...@gmail.com wrote:

I assume that when you don't specify any field, and you get nothing back,
is because you disabled the _source field. If you want ot get all the
stored fields, then yes, you need to do: addField("*"), why is this ugly?

Btw, most times, going each field specifically stored is wrong, and
_source
should be used.

On Thu, Nov 24, 2011 at 2:04 AM, ikarius frederic.ver...@gmail.com
wrote:

Hi all,

First, i'm a beginner with ES, so .. be kind (though i've a strong
background with Lucene).

I'm trying to get all the stored fields (with a mapping) in my seach.
These
stored fields seems to be stored alright, thic code:

  SearchResponse rsp = getClient().prepareSearch(INDEX_SKIMM)
          .setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
          .setQuery(q)
          .addField("firstname")
          .setFrom(startIndex)
          .setSize(limit > MAX_RESULTS ? MAX_RESULTS : limit )
          .setExplain(true)
          .execute()
          .actionGet();

returns me the 'firstname' field in my SearchHit;

But, if i remove the
.addField("firstname")
line, i do not get ANY of my stored fields.

Is it normal ?

I've found a (ugly) workaround by adding this line in the search:
.addField("*")

and i gain access to all stored fields.

Thanks in advance for your answers !

Missed it, sorry.
Thanks again

On 24 nov, 19:23, Shay Banon kim...@gmail.com wrote:

Yea, its documented:Elasticsearch Platform — Find real-time answers at scale | Elastic.

On Thu, Nov 24, 2011 at 7:12 PM, ikarius frederic.ver...@gmail.com wrote:

Well ugly was a bit too much. But is this option documented ?
I tried this "at random" and it worked.

On 24 nov, 14:52, Shay Banon kim...@gmail.com wrote:

I assume that when you don't specify any field, and you get nothing back,
is because you disabled the _source field. If you want ot get all the
stored fields, then yes, you need to do: addField("*"), why is this ugly?

Btw, most times, going each field specifically stored is wrong, and
_source
should be used.

On Thu, Nov 24, 2011 at 2:04 AM, ikarius frederic.ver...@gmail.com
wrote:

Hi all,

First, i'm a beginner with ES, so .. be kind (though i've a strong
background with Lucene).

I'm trying to get all the stored fields (with a mapping) in my seach.
These
stored fields seems to be stored alright, thic code:

  SearchResponse rsp = getClient().prepareSearch(INDEX_SKIMM)
          .setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
          .setQuery(q)
          .addField("firstname")
          .setFrom(startIndex)
          .setSize(limit > MAX_RESULTS ? MAX_RESULTS : limit )
          .setExplain(true)
          .execute()
          .actionGet();

returns me the 'firstname' field in my SearchHit;

But, if i remove the
.addField("firstname")
line, i do not get ANY of my stored fields.

Is it normal ?

I've found a (ugly) workaround by adding this line in the search:
.addField("*")

and i gain access to all stored fields.

Thanks in advance for your answers !

Hi,

Even though i enabled _source during mapping, i am not getting results without .addField("*"),
I am also getting a score of 1 for all results.

Please help me out.