Top documents sorted by a particular field


(Frank LaRosa) #1

Hi,

I want to find the top N documents in my index sorted by a particular
field, using a filter.

I find that I cannot combine a filter with a Match All query. The
filter seems to have no effect, returning the top documents in the
entire index every time regardless of the filter value.

Using the filter in conjunction with a query works.

What can I do?


(Karussell) #2

Have a look

http://www.elasticsearch.org/guide/reference/api/search/

Peter.

On 25 Jan., 00:36, Frank LaRosa fr...@studyblue.com wrote:

Hi,

I want to find the top N documents in my index sorted by a particular
field, using a filter.

I find that I cannot combine a filter with a Match All query. The
filter seems to have no effect, returning the top documents in the
entire index every time regardless of the filter value.

Using the filter in conjunction with a query works.

What can I do?


(Karussell) #3

BTW: Sorting != filter. The sorting is achieved with 'sort' and filter
would restrict your search results ...

On 25 Jan., 00:36, Frank LaRosa fr...@studyblue.com wrote:

Hi,

I want to find the top N documents in my index sorted by a particular
field, using a filter.

I find that I cannot combine a filter with a Match All query. The
filter seems to have no effect, returning the top documents in the
entire index every time regardless of the filter value.

Using the filter in conjunction with a query works.

What can I do?


(Frank LaRosa) #4

Thanks, I seem to have gotten it to work.

On a related note -- is filtering possible on any field, or just
indexed fields?

On Jan 25, 2:25 am, Karussell tableyourt...@googlemail.com wrote:

BTW: Sorting != filter. The sorting is achieved with 'sort' and filter
would restrict your search results ...

On 25 Jan., 00:36, Frank LaRosa fr...@studyblue.com wrote:

Hi,

I want to find the top N documents in my index sorted by a particular
field, using a filter.

I find that I cannot combine a filter with a Match All query. The
filter seems to have no effect, returning the top documents in the
entire index every time regardless of the filter value.

Using the filter in conjunction with a query works.

What can I do?


(Shay Banon) #5

Just indexed fields mainly, though you can have a script filter with a script that uses _source to load and parse the source to get a value and filter by it (which is expensive).

On Wednesday, January 25, 2012 at 7:04 PM, Frank LaRosa wrote:

Thanks, I seem to have gotten it to work.

On a related note -- is filtering possible on any field, or just
indexed fields?

On Jan 25, 2:25 am, Karussell <tableyourt...@googlemail.com (http://googlemail.com)> wrote:

BTW: Sorting != filter. The sorting is achieved with 'sort' and filter
would restrict your search results ...

On 25 Jan., 00:36, Frank LaRosa <fr...@studyblue.com (http://studyblue.com)> wrote:

Hi,

I want to find the top N documents in my index sorted by a particular
field, using a filter.

I find that I cannot combine a filter with a Match All query. The
filter seems to have no effect, returning the top documents in the
entire index every time regardless of the filter value.

Using the filter in conjunction with a query works.

What can I do?


(system) #6