Unexpected behaviour using from / size


(Runar Myklebust-2) #1

Im doing some unit-tests and gets some unexpected result when using the
from and size parameters:

I add two documents to the index, with ids 1 and 2.

When querying like this:

{
"from" : 0,
"size" : 2,
"query" : {
"match_all" : {
}
}
}

I get results as expected:

searchHits.getHits().length = 2
searchHits.getTotalHits() = 2

When I do this query instead:

{
"from" : 1,
"size" : 2,
"query" : {
"match_all" : {
}
}
}

I get this result, which for me seem to be wrong:

searchHits.getHits().length = 0
searchHits.getTotalHits() = 2

I would have expected to get a hit?

Im using v 0.18.6

mvh

Runar Myklebust


(Shay Banon) #2

Which search type are you using?

On Mon, Jan 2, 2012 at 4:00 PM, Runar Myklebust runar@myklebust.me wrote:

Im doing some unit-tests and gets some unexpected result when using the
from and size parameters:

I add two documents to the index, with ids 1 and 2.

When querying like this:

{
"from" : 0,
"size" : 2,
"query" : {
"match_all" : {
}
}
}

I get results as expected:

searchHits.getHits().length = 2
searchHits.getTotalHits() = 2

When I do this query instead:

{
"from" : 1,
"size" : 2,
"query" : {
"match_all" : {
}
}
}

I get this result, which for me seem to be wrong:

searchHits.getHits().length = 0
searchHits.getTotalHits() = 2

I would have expected to get a hit?

Im using v 0.18.6

mvh

Runar Myklebust


(Runar Myklebust-2) #3

Query And Fetch

On Mon, Jan 2, 2012 at 3:04 PM, Shay Banon kimchy@gmail.com wrote:

Which search type are you using?

On Mon, Jan 2, 2012 at 4:00 PM, Runar Myklebust runar@myklebust.mewrote:

Im doing some unit-tests and gets some unexpected result when using the
from and size parameters:

I add two documents to the index, with ids 1 and 2.

When querying like this:

{
"from" : 0,
"size" : 2,
"query" : {
"match_all" : {
}
}
}

I get results as expected:

searchHits.getHits().length = 2
searchHits.getTotalHits() = 2

When I do this query instead:

{
"from" : 1,
"size" : 2,
"query" : {
"match_all" : {
}
}
}

I get this result, which for me seem to be wrong:

searchHits.getHits().length = 0
searchHits.getTotalHits() = 2

I would have expected to get a hit?

Im using v 0.18.6

mvh

Runar Myklebust

--
mvh

Runar Myklebust


(Shay Banon) #4

Thats the problem, query_and_fetch returns size docs from each shard, and
then the from is again shard related. Use query_then_fetch, which is the
default (and the one people should use 99.999% of the time).

On Mon, Jan 2, 2012 at 4:15 PM, Runar Myklebust runar@myklebust.me wrote:

Query And Fetch

On Mon, Jan 2, 2012 at 3:04 PM, Shay Banon kimchy@gmail.com wrote:

Which search type are you using?

On Mon, Jan 2, 2012 at 4:00 PM, Runar Myklebust runar@myklebust.mewrote:

Im doing some unit-tests and gets some unexpected result when using the
from and size parameters:

I add two documents to the index, with ids 1 and 2.

When querying like this:

{
"from" : 0,
"size" : 2,
"query" : {
"match_all" : {
}
}
}

I get results as expected:

searchHits.getHits().length = 2
searchHits.getTotalHits() = 2

When I do this query instead:

{
"from" : 1,
"size" : 2,
"query" : {
"match_all" : {
}
}
}

I get this result, which for me seem to be wrong:

searchHits.getHits().length = 0
searchHits.getTotalHits() = 2

I would have expected to get a hit?

Im using v 0.18.6

mvh

Runar Myklebust

--
mvh

Runar Myklebust


(Runar Myklebust-2) #5

Thanks, by mistake I thought the Query And Fetch was the default. Maybe it
could be mentioned in the Search API - Search Type documentation?

On Mon, Jan 2, 2012 at 3:17 PM, Shay Banon kimchy@gmail.com wrote:

Thats the problem, query_and_fetch returns size docs from each shard, and
then the from is again shard related. Use query_then_fetch, which is the
default (and the one people should use 99.999% of the time).

On Mon, Jan 2, 2012 at 4:15 PM, Runar Myklebust runar@myklebust.mewrote:

Query And Fetch

On Mon, Jan 2, 2012 at 3:04 PM, Shay Banon kimchy@gmail.com wrote:

Which search type are you using?

On Mon, Jan 2, 2012 at 4:00 PM, Runar Myklebust runar@myklebust.mewrote:

Im doing some unit-tests and gets some unexpected result when using the
from and size parameters:

I add two documents to the index, with ids 1 and 2.

When querying like this:

{
"from" : 0,
"size" : 2,
"query" : {
"match_all" : {
}
}
}

I get results as expected:

searchHits.getHits().length = 2
searchHits.getTotalHits() = 2

When I do this query instead:

{
"from" : 1,
"size" : 2,
"query" : {
"match_all" : {
}
}
}

I get this result, which for me seem to be wrong:

searchHits.getHits().length = 0
searchHits.getTotalHits() = 2

I would have expected to get a hit?

Im using v 0.18.6

mvh

Runar Myklebust

--
mvh

Runar Myklebust

--
mvh

Runar Myklebust


(system) #6