Get all *STORED* fields from a query


(ikarius) #1

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 !


(system) #2