# Named Queries, inconsistent behaviour

**URL:** <https://discuss.elastic.co/t/named-queries-inconsistent-behaviour/87509>\
**Category:** Elasticsearch\
**Created:** [May 30, 2017, 6:42am UTC](https://discuss.elastic.co/t/named-queries-inconsistent-behaviour/87509 "2017-05-30T06:42:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vishva\_deepak\_tewari](https://avatars.discourse-cdn.com/v4/letter/v/f07891/32.png) [@vishva\_deepak\_tewari](https://discuss.elastic.co/u/vishva_deepak_tewari)\
**Post date:** [May 30, 2017, 6:42am UTC](https://discuss.elastic.co/t/named-queries-inconsistent-behaviour/87509/1 "2017-05-30T06:42:16Z")

</div>

Hi,  
I am using elastic search 5.2.1 , I am seeing inconsistent behaviour in named queries, for some queries i am getting matched queries in response, while in certain queries i am not getting matched queries, some times i am getting matched queries in few records, and for few i am not getting. All these have been performed on the same index.

The query for which I got no matched queries is as follows

{  
"query": {  
"nested": {  
"query" : {  
"multi\_match" : {  
"query" : "production engineer",  
"fields" : [  
"company^1.0",  
"keywordSet^5.0",  
"qualification^2.0",  
"rawJobColl.description^1.0",  
"rawJobColl.metadataStr^5.0",  
"rawJobColl.name^5.0"  
],  
"type" : "best\_fields",  
"operator" : "OR",  
"slop" : 0,  
"\_name" : "production engineer"  
}  
},  
"path" : "rawJobColl",  
"score\_mode" : "sum"  
}  
}  
}

However if i run this query

{  
"query" : {  
"bool" : {  
"must" : [  
{  
"function\_score" : {  
"query" : {  
"nested" : {  
"query" : {  
"bool" : {  
"should" : [  
{  
"multi\_match" : {  
"query" : "production engineer",  
"fields" : [  
"company^1.0",  
"keywordSet^5.0",  
"qualification^2.0",  
"rawJobColl.description^1.0",  
"rawJobColl.metadataStr^5.0",  
"rawJobColl.name^5.0"  
],  
"type" : "best\_fields",  
"\_name" : "production engineer"  
}  
}  
]  
}  
},  
"path" : "rawJobColl"  
}  
}  
}  
}  
],  
"filter" : [  
{  
"bool" : {  
"must" : [  
{  
"nested" : {  
"query" : {  
"bool" : {  
"must" : [  
{  
"terms" : {  
"jobKeywords.keywordId" : [  
32  
],  
"boost" : 1.0  
}  
}  
]  
}  
},  
"path" : "jobKeywords"  
}  
}  
]  
}  
}  
]  
}  
},  
"\_source" : {  
"includes" : [  
"id",  
"name"  
],  
"excludes" : []  
}  
}

I get matched queries, both of these queries are being run on the same index and type.

Please let me know what is going on?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 27, 2017, 6:42am UTC](https://discuss.elastic.co/t/named-queries-inconsistent-behaviour/87509/2 "2017-06-27T06:42:51Z")

</div>

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