Different result between java client api and query dsl?

i am using the 2.3.5 version elasticsearch ,this is the whole data:

==================================

{
"hits": {
"total": 4,
"max_score": 1,
"hits": [
{
"_index": "testindex",
"_type": "testtype",
"_id": "AVvxdNN3mqK8n_bRen0r",
"_score": 1,
"_source": {
"age": 325,
"about": "gasdf ghasd"
}
}
,
{
"_index": "testindex",
"_type": "testtype",
"_id": "AVvxdOE-mqK8n_bRen0s",
"_score": 1,
"_source": {
"age": 335,
"about": "gasdf ghasd"
}
}
,
{
"_index": "testindex",
"_type": "testtype",
"_id": "AVvxdMdjmqK8n_bRen0q",
"_score": 1,
"_source": {
"age": 35,
"about": "gasdf ghasd"
}
}
,
{
"_index": "testindex",
"_type": "testtype",
"_id": "AVvxdJXLmqK8n_bRen0p",
"_score": 1,
"_source": {
"age": 25,
"about": "gasdf ghasd"
}
}
]
}
}

====================
when i am using java client api for searching:

    QueryBuilder qb = QueryBuilders.termQuery("age","25");
    SearchRequestBuilder builder = client.prepareSearch("testindex");
    SearchResponse res = builder.setTypes("testtype").setQuery(qb).execute().actionGet();
    SearchHits hits = res.getHits();

it returns only one hit that the age equal 25

but when i am using query dsl in head plugin:

{"query":{"term":{"age":"25"}}}

it returned all the document

"hits": {
"total": 4,
"max_score": 1,
"hits": [
{
"_index": "testindex",
"_type": "testtype",
"_id": "AVvxdNN3mqK8n_bRen0r",
"_score": 1,
"_source": {
"age": 325,
"about": "gasdf ghasd"
}
}
,
{
"_index": "testindex",
"_type": "testtype",
"_id": "AVvxdOE-mqK8n_bRen0s",
"_score": 1,
"_source": {
"age": 335,
"about": "gasdf ghasd"
}
}
,
{
"_index": "testindex",
"_type": "testtype",
"_id": "AVvxdMdjmqK8n_bRen0q",
"_score": 1,
"_source": {
"age": 35,
"about": "gasdf ghasd"
}
}
,
{
"_index": "testindex",
"_type": "testtype",
"_id": "AVvxdJXLmqK8n_bRen0p",
"_score": 1,
"_source": {
"age": 25,
"about": "gasdf ghasd"
}
}
]
}

am i using the wrong api??thx buddy

Please format your code using </> icon as explained in this guide. It will make your post more readable.

Or use markdown style like:

```
CODE
```

Probably a bug with HEAD plugin as it does not support GET with body.
Try with POST or use Kibana Dev Console.

thanks, i will try with POST later

thanks again,using POST method got the correct result

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.