Facets using field or script_field?

Hello,

I am trying to improve the performance of my faceted search requests and I
found something interesting: for the tests I was doing, changing the facet
term from:

"field": ""

to

"script_field": "doc[''].value"

made my query 8x faster. Later, in some tests, it reached 42x!. I didn't
understand it, but I was happy...
... and then, testing a particularly heavy query (the top facet has a count
of 995869), it went the other way round: the query was 2x slower.

So my question is: what is the difference? what should I use?

I've read that Elasticsearch loads all facets, so I tried preventing this
by copying the main query in a facet filter ("facet_filter": { "query":
<main_query> }), but it just gets worse.

The facet field is stored and my HQ plugin says there have been 0 field
evictions in a field cache of 488.7 mb.

Thanks.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.