How to Select * from Doc where description like '%keju%' and purchasedId = 'PG.R.UNC.01'

Hello, i'm new on elastic search, still not understand how using query for elastic search

i have data

like this one

{
	"_index" : "normal",
	"_type" : "product",
	"_id" : "002417",
	"_score" : 0.93070257,
	"_source" : {	
		"ListPurchasedGroupId" : [
			{
				"Value" : "PG.R.BKS.01"
			},
			{
				"Value" : ""PG.R.UNC.01""
			}
		],

		"ProductId" : "002417",
		"Name" : "Richeese Bisvit Selimut Rch 20 x 11 g",
		"BrandName" : "",
		"PrincipalName" : "Nabati",
		"Description" : "Biskuit sandwich salut krim keju",
		"RelevanceName" : "biskuit",
		"DtmLastUpdate" : "2019-09-16T20:59:31"
	}
},
{
    "_index" : "normal",
    "_type" : "product",
    "_id" : "002418",
    "_score" : 4.82661,
    "_source" : {
        "ListPurchasedGroupId" : [
            {
                "Value" : "PG.R.BKS.01"
            }
        ],

        "ProductId" : "002418",
        "Name" : "Richeese Biscuit Selimut Rch 50 x 11 g",
        "BrandName" : "",
        "PrincipalName" : "Nabati",
        "Description" : "Biskuit sandwich salut krim keju enak",
        "RelevanceName" : "biskuit",
        "DtmLastUpdate" : "2019-09-16T20:59:31"
    }
},

how can i select data by Description AND by ListPurchasedGroupId.Value

already trying using this

GET /normal/product/_search
{
  "query": {
    "bool": {
      "must": [
          {
            "match": {
              "Description" : "Keju "
            }
          },
          {
            "nested": {
              "path": "ListPurchasedGroupId",
              "query": {
                  "bool":{
                      "must":[
                        {
                          "match": {"ListPurchasedGroupId.Value": "PG.R.UNC.01"}
                        }  
                      ]
                  }
              }
            }
          }
      ]
    }
  }
}

but i still got the productId 002418
this product didnt have purchasedGroupId = "PG.R.UNC.01"
how to fix it?

Could you provide a full recreation script as described in About the Elasticsearch category. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

1 Like

What is the mapping for those fields? Are they by any chance text?

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