I think this is a bug indeed. The QUERY_AND_FETCH search mode has been
designed as an optimization of QUERY_THE_FETCH for the single shard case
(which is typically the case when you use routing) rather than a search
mode on its own.

As a side note, using QUERY_AND_FETCH when paginating on several shards
would be very bad as it would be much more I/O and memory intensive than
QUERY_THEN_FETCH. So while we could fix it to return correct results when
paginating, maybe the right fix would rather be to fix documentation to
document this search type as an internal optinmization for the single-shard
case which should not be used explicitely.



On Sat, Feb 7, 2015 at 3:58 AM, Hardik Dobariya <
hardikdobariya1...@gmail.com> wrote:

> According to Elastic search
> <http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-search-type.html#query-and-fetch>
>  if
> working with Query_and_fetch will return size times number of shards
> hits.Following this rule I implemented below query using Nest having 5
> shards
>
> int from = 0;
>         int size = 1;
>
>          while (true)
>         {
>             var result = client.Search<object>(x => x
>            .SearchType(SearchType.QueryAndFetch)
>            .Size(size)
>            .From(from * size)
>            .Query(qr => qr.MatchAll())
>            );
>
>             if (result.Hits.Count() == 0)
>             {
>                 break;
>             }
>            from++;
>         }
>
>
> If I have total 17 records in index then according to the rule above query
> should execute 4 times returning 5,5,5,2 = 17 total records but this is not
> the case in the above query.
> Above query executes 4 times returning 5,3,3,1 = 12 records missing 5
> records.
> Am I doing anything wrong or missing anything?
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elasticsearch/311c56ad-c3b9-4aa7-b268-9c3c92e21e55%40googlegroups.com
> <https://groups.google.com/d/msgid/elasticsearch/311c56ad-c3b9-4aa7-b268-9c3c92e21e55%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Adrien Grand

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j66-8r9dd6HXEPm7rcpARVutbWZOKAMUWN0ng5y6Qq3Qw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to