Count api not giving the consistent result for different datatypes

Hi there,
I need to use the count api for counting the document. and its
giving me the correct results if the use the string field in query. but if
i query in the numeric field, its giving 0 count always although, the
document count is not zero.

for example :

and two type of docs are

type :A
{
"title": "abc",
"state_guid": 15678}

type:B
{
name:"xyz",
state_guid: 15678}

if the query is this:
{"query":
{"term":
{state_guid:"15678"
}
}
}

so if the query is run on the type A, its giving correct count results ,
but zero in case of type: B
Can anyone please explain this and if possible please give the solution
without reindexing the data

On Friday, March 30, 2012 5:43:37 PM UTC+5:30, Narinder Kaur wrote:

Hi there,
I need to use the count api for counting the document. and its
giving me the correct results if the use the string field in query. but if
i query in the numeric field, its giving 0 count always although, the
document count is not zero.

for example :

and two type of docs are

type :A
{
"title": "abc",
"state_guid": 15678}

type:B
{
name:"xyz",
state_guid: "15678"}

if the query is this:
{"query":
{"term":
{state_guid:"15678"
}
}
}

so if the query is run on the type A, its giving correct count results ,
but zero in case of type: B
Can anyone please explain this and if possible please give the solution
without reindexing the data

  • Are you sure both types are marked as numeric? Can you do get mapping and
    verify?

  • Are you executing the search explicitly against the type?

On Fri, Mar 30, 2012 at 3:13 PM, Narinder Kaur narinder.kaur@izap.inwrote:

Hi there,
I need to use the count api for counting the document. and its
giving me the correct results if the use the string field in query. but if
i query in the numeric field, its giving 0 count always although, the
document count is not zero.

for example :

and two type of docs are

type :A
{
"title": "abc",
"state_guid": 15678}

type:B
{
name:"xyz",
state_guid: 15678}

if the query is this:
{"query":
{"term":
{state_guid:"15678"
}
}
}

so if the query is run on the type A, its giving correct count results ,
but zero in case of type: B
Can anyone please explain this and if possible please give the solution
without reindexing the data