Not able to limit size of result


(James Cook) #1

I am executing the following query, but my result set contains 10 items even
though I am trying to limit it to 3. Any tips?

{
"size": 4,
"query" : {
"bool" : {
"must" : {
"field" : { "mimetype" : "text/html" }
},
"must" : {
"field" : { "locale" : "en" }
}
}
}
}

Result:

{
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 8,
"hits" : [ {...} ]
}
}


(Lukáš Vlček) #2

Hi,

interesting. Limit on size works quite good for me. Are you able to
replicate this with curl and some simple testing data?
BTW: Just to be sure I understand you correctly, you are saying that with
the json snippets in your email you are getting more then 4 items in the
hits.hits[] array?

Regards,
Lukas

On Mon, Sep 13, 2010 at 1:57 AM, James Cook jcook@tracermedia.com wrote:

I am executing the following query, but my result set contains 10 items
even though I am trying to limit it to 3. Any tips?

{
"size": 4,
"query" : {
"bool" : {
"must" : {
"field" : { "mimetype" : "text/html" }
},
"must" : {
"field" : { "locale" : "en" }
}
}
}
}

Result:

{
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 8,
"hits" : [ {...} ]
}
}


(Shay Banon) #3

The total marker returns the total hits for the mentioned query across all
relevant data. The elements in the hits will be bounded by the size
parameter (except when using search_type of query_and_fetch).

On Mon, Sep 13, 2010 at 11:43 AM, Lukáš Vlček lukas.vlcek@gmail.com wrote:

Hi,

interesting. Limit on size works quite good for me. Are you able to
replicate this with curl and some simple testing data?
BTW: Just to be sure I understand you correctly, you are saying that with
the json snippets in your email you are getting more then 4 items in the
hits.hits[] array?

Regards,
Lukas

On Mon, Sep 13, 2010 at 1:57 AM, James Cook jcook@tracermedia.com wrote:

I am executing the following query, but my result set contains 10 items
even though I am trying to limit it to 3. Any tips?

{
"size": 4,
"query" : {
"bool" : {
"must" : {
"field" : { "mimetype" : "text/html" }
},
"must" : {
"field" : { "locale" : "en" }
}
}
}
}

Result:

{
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 8,
"hits" : [ {...} ]
}
}


(system) #4