Should query for nested objects


(Danielpt17) #1

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 !


(system) #2

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