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?
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.
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?
So I cannot use QUERY_AND_FETCH because this would be very expensive
regarding high I/O and memory intensive.
The following is the reason I want to use QUERY_AND_FETCH because
If I use QUERY_THEN_FETCH then according to Elastic search QUERY_AND_FETCH
is very fast because it does not sort the result on score
and QUERY_THEN_FETCH first fetch result from all shards ,perform sorting
on score then returns the result.
I do not want sorting on the result so I want to use QUERY_AND_FETCH.
Is there any other alternative for the same?
How about using scantype=scan?will it be a good practice to use it or this
will would also be expensive regarding high I/O and memory intensive
On Monday, February 9, 2015 at 12:33:56 AM UTC+5:30, Adrien Grand wrote:
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 <hardikdob...@gmail.com
<javascript:>> wrote:
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?
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.