# Should query for nested objects

**URL:** <https://discuss.elastic.co/t/should-query-for-nested-objects/117415>\
**Category:** Elasticsearch\
**Created:** [January 29, 2018, 8:36am UTC](https://discuss.elastic.co/t/should-query-for-nested-objects/117415 "2018-01-29T08:36:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielpt17](https://avatars.discourse-cdn.com/v4/letter/d/ba8739/32.png) [@danielpt17](https://discuss.elastic.co/u/danielpt17)\
**Post date:** [January 29, 2018, 8:36am UTC](https://discuss.elastic.co/t/should-query-for-nested-objects/117415/1 "2018-01-29T08:36:48Z")

</div>

Hi,  
I am working on an app that searches dishes in restaurant menus.  
(i am using Elastic search for my DB ).  
i seem to have a problem when i search for my input in dish description or dish price- it doesn't seem to find the input in my DB - even though i have that input stored in my DB!!

here is my mapping :

```
"mappings": 
	{
		"restaurants":
		{
			"properties": 
			{
				"rest_name":
				{
					"type":"text"
				},
				"rest_zip":
				{
					"type":"integer"
				},
				"Kosher":
				{
					"type":"boolean"
				},
				"rest_address":
				{
					"type":"text"
				},
				"rest_location":
				{
					"type":"geo_point"
				},
				"rest_desc":
				{
					"type":"text"
				},
				"menu":
				{
					"type":"nested",
					"properties": 
					{
						"dish_name":
						{
						  "type":"keyword"
						},
						"dish_description":
						{
						  "type":"text"
						},
						"dish_price":
						{
						  "type":"double"
						},
						"dish_id_inRest":
						{
						  "type": "double"
						}
					}
				}
			}
		}
	}`

```

> Preformatted text

`

here is my query :

```
		    body :{
				query: {     
					nested: {
						path: 'menu',
							"inner_hits": { 
								//explain:true,
								_source: ['menu.dish_name','menu.dish_description','menu.dish_price']
							
							},
							 "query": {
								 "bool" : {
									"should": { 
										"query": {
											"match": {//dosent work 
												"menu.dish_description":{
													"query": dish_name 
													 //"operator": "and"
													//"minimum_should_match": "75%"
												}
											}
										}
									},
									"should" : [//works
										{"term": {"menu.dish_name": dish_name}},
									]
								//	"minimum_should_match": 1
								 }	
							 }
					}
				}				
			}

```

this is my object:

```
{
  "_index": "hungrymonkeyrests",
  "_type": "restaurants",
  "_id": "0",
  "_version": 2,
  "_score": 1,
  "_source": {
    "rest_address": "הכינור 19/4 מעלה אדומים",
    "rest_desc": "",
    "rest_location": {
      "lon": 35.2970654,
      "lat": 31.7824196
    },
    "rest_name": "מסעדת שקשוקה",
    "Kosher": true,
    "menu": [
      {
        "dish_name": "שקשוקה ירוקה",
        "dish_description": "שקשקה תרד עם הרבה גבינה ",
        "dish_price": "55",
        "dish_id_inRest": 0
      },
      {
        "dish_name": "שקשוקה צרפתית",
        "dish_description": "שקשוקה בסגנון צרפתי עם תרד והרבה גבינה",
        "dish_price": "40",
        "dish_id_inRest": 0.1
      },
      {
        "dish_name": "שקשוקה אדומה",
        "dish_description": "שקשוקה רגילה",
        "dish_price": "60",
        "dish_id_inRest": 0.2
      }
    ]
  }
}

```

and here is the string i search for (my input) :  
{"dishName": "שקשוקה ירוקה"}

can anyone tell me what's wrong with my query ??  
thanks a lot !

---

<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:** [February 26, 2018, 8:37am UTC](https://discuss.elastic.co/t/should-query-for-nested-objects/117415/2 "2018-02-26T08:37:15Z")

</div>

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