# Multi Field query with query\_string over property and nested object

**URL:** <https://discuss.elastic.co/t/multi-field-query-with-query-string-over-property-and-nested-object/139194>\
**Category:** Elasticsearch\
**Created:** [July 9, 2018, 2:23pm UTC](https://discuss.elastic.co/t/multi-field-query-with-query-string-over-property-and-nested-object/139194 "2018-07-09T14:23:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![MarcusK](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marcusk/32/34033_2.png) [@MarcusK](https://discuss.elastic.co/u/MarcusK)\
**Post date:** [July 9, 2018, 2:23pm UTC](https://discuss.elastic.co/t/multi-field-query-with-query-string-over-property-and-nested-object/139194/1 "2018-07-09T14:23:24Z")

</div>

I'm trying to solve the following high level requirement:

- save arbitrary number of key value pairs on a document with properties: name and description
- values can be numbers which should be 'range searchable'
- values can include geo\_points which need to be 'geo searchable'

I've created the following index.

`{ "settings": { "index" : { "number_of_shards" : 3, "number_of_replicas" : 1 } }, "mappings": { "_doc": { "dynamic": "strict", "properties": { "name": { "type": "text", "analyzer": "german", }, "description": { "type": "text", "analyzer": "german" }, "attributes": { "type": "nested", "properties": { "key": { "type": "text" }, "val_bool": { "type": "boolean" }, "val_int": { "type": "integer" }, "val_float": { "type": "float" }, "val_string": { "type": "text" }, "val_geo": { "type": "geo_point" }, "val_date": { "type": "date" } } } } } } }`

We use nested objects to be able to save a list of key-value-pairs for each document. Each key-value-pair uses one typed val\_\* property to persist the value.

To search in documents we use query\_string query to allow users to be very specific in searches. For example. Search documents where name:foo AND description:bar. (that works as expected)

The same scenario should be possible with key-value-pairs.So for example:  
attributes.key:someKey AND attributes.val\_string:someStringValue.  
This scenario requires a nested query which we use and works as expected.

What isnt't working:  
If we search for name:foo AND attributes.key:someKey we get no results.

It's seems that 'nested query\_string queries' AND 'just query\_string queries' arent't supported in combination. Is that true?  
What's a feasible workaround to implement the described requirement?

Any help is greatly appreciated. Thank you in advance.

---

<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:** [August 6, 2018, 2:23pm UTC](https://discuss.elastic.co/t/multi-field-query-with-query-string-over-property-and-nested-object/139194/2 "2018-08-06T14:23:25Z")

</div>

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