Questions about using must, should words together and Turkish char problem

Hello

I am using Elasticsearch-oss-7.10.2-1.x86_64. I have 2 questions:

Question 1)

I want to combine this query results:

GET /turkish_example/_search
{
  "query": {
		"bool": {
		  "should": [
			  {
				  "simple_query_string": {
					"fields" : ["adi1","adi2","cevirmen","yazar","sku","listprice"],
					"query" : "MÜBECCEL KIRAY",
								"default_operator": "and"
				  }
			  },
			  {
				  "simple_query_string": {
					"fields" : ["adi1","adi2","cevirmen","yazar","sku","listprice"],
					"query" : "MÜBECCEL KıRAY",
								"default_operator": "and"
				  }
			  },			  
			  {"term": {"adi1": "Mübeccel B. Kıray"}},
			  {"term": {"adi2": "Mübeccel B. Kıray"}}			  
		  ]
		
	  }
  },
  "size": 200,
  "_source": true,
  "fields":["adi1","adi2","sku","cevirmen","basim_tarihi","basim_yeri", "sayfa_sayisi","yazar"]
}

with:

{ 
          "bool": {
      "must_not": [
        { 
          "term": {
            "localinventory": "0"
          }
}

I want to show all results of first query if localinventory is not 0. Is it posible to use should and must words together?

How can I do that?

Question 2)

When I searched for "MÜBECCEL KIRAY" only, I cannot see results properly. I think this problem is related with Turkish chars. Upper I letter should be converted as (lower ı or lower i). I solved this problem by adding some additional queries with "should" word. Is there another suggestion for solving this problem. If I use a single query by replacing I char with ı this time my query doesn't work for "Gurbetteki Kafkasya II". Because II letters shouldn't be replaced like ıı... Using 2 queries solved my problem. Do you have different suggestions?

I tried to create an index by following this document but it didn't help.

I solved this by using following syntax:

GET /kutuphane/_search
{
   "query":{
      "bool":{
         "must":[
            {
               "simple_query_string":{
                  "fields":[
                     "adi1",
                     "adi2",
                     "cevirmen",
                     "yazar",
                     "sku",
                     "listprice"
                  ],
                  "query":"(MÜBECCEL KIRAY' | MÜBECCEL KıRAY)",
                  "default_operator":"and"
               }
            },
            {
               "bool":{
                  "should":[
                     {
               "simple_query_string":{
                  "fields":[
                     "adi1",
                     "adi2",
                     "cevirmen",
                     "yazar",
                     "sku",
                     "listprice"
                  ],
                  "query":"(MÜBECCEL KIRAY' | MÜBECCEL KıRAY)",
                  "default_operator":"and"
               }
            },
                          {"term": {"adi1": "MÜBECCEL KIRAY"}},
                          {"term": {"adi2": "MÜBECCEL KIRAY"}}
            
                  ]
               }
            },
            {
               "bool":{
                  "must_not":[
                     {
                        "term":{
                           "localinventory":"0"
                        }
                     }
                  ]
               }
            }
         ]
      }
   },
   "size":200,
   "_source":true,
   "fields":[
      "adi1",
      "adi2",
      "sku",
      "cevirmen",
      "basim_tarihi",
      "basim_yeri",
      "sayfa_sayisi",
      "yazar"
   ]
}

But I will be happy to hear different suggestions. I am new on ELK queries.

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