# Why is this query not working?

**URL:** <https://discuss.elastic.co/t/why-is-this-query-not-working/13873>\
**Category:** Elasticsearch\
**Created:** [October 7, 2013, 9:16pm UTC](https://discuss.elastic.co/t/why-is-this-query-not-working/13873 "2013-10-07T21:16:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dantuff](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@dantuff](https://discuss.elastic.co/u/dantuff)\
**Post date:** [October 7, 2013, 9:16pm UTC](https://discuss.elastic.co/t/why-is-this-query-not-working/13873/1 "2013-10-07T21:16:31Z")

</div>

I have both 'title' and 'name' fields that are objects and can contain  
multiple locales, i.e.

"title": {  
"properties": {  
"en": {  
...  
},  
"es" :{  
...  
}  
}  
}

"name": {  
"properties": {  
"en": {  
...  
},  
"es" :{  
...  
}  
}  
}

If I do a search on the English title field:

{  
"from" : 0,  
"size" : 20,  
"query" : {  
"query\_string" : {  
"query" : "title.en:elastic"  
}  
}  
}

I am getting a match on the 'name' field. When I look at the translated  
Lucene query in Inquistor it translates to:

en:elastic

Why is it removing the 'title' field from the query?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![brian\_yoder](https://avatars.discourse-cdn.com/v4/letter/b/f1d935/32.png) [@brian\_yoder](https://discuss.elastic.co/u/brian_yoder)\
**Post date:** [October 8, 2013, 4:17pm UTC](https://discuss.elastic.co/t/why-is-this-query-not-working/13873/2 "2013-10-08T16:17:03Z")

</div>

Dan,

It appears as if you are defining title and name as types, not as fields.  
Both types have the en field, and for a query that doesn't restrict based  
on types it searches the en field in both of the types.

What you really want is the title and name fields defined as _multi\_field_mappings within some type. And then the sub-mapping of the same name is the  
default. For example, here is an excerpt of one of my own field mappings  
from an exploratory schema. It is for the _cn_ (common name, in LDAP  
parlance) field:

"_cn_" : {  
"type" : "multi\_field",  
"fields" : {  
"_cn_" : {  
"type" : "string",  
"analyzer" : "english\_stemming\_analyzer"  
},  
"_finnish_" : {  
"type" : "string",  
"analyzer" : "finnish\_stemming\_analyzer"  
},  
"_arabic_" : {  
"type" : "string",  
"analyzer" : "arabic\_stemming\_Arabic\_analyzer"  
},  
"_raw_" : {  
"type" : "string",  
"index" : "not\_analyzed"  
}  
}  
},

Then, a Lucene query string for cn: chooses the english\_stemming\_analyzer,  
while cn.finnish chooses the finnish\_stemming\_analyzer. And so on. Of  
course, the actual specifications of these analyzers is not shown here.

Hope this helps.

Brian

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [July 6, 2017, 2:13am UTC](https://discuss.elastic.co/t/why-is-this-query-not-working/13873/3 "2017-07-06T02:13:19Z")

</div>


