Case Sensitive query?


(Derrick) #1

Hi, I have an issue with query, I want the search case insensitive, but I don't know what's wrong with my mapping file?

the below query returns result properly.

{
  "query": {
    "bool": {
      "must": [
        {
          "wildcard": {
            "booking.cparty1": {
              "wildcard": "manitoba*",
              "boost": 1
            }
          }
        }
      ],
      "disable_coord": false,
      "adjust_pure_negative": true,
      "boost": 1
    }
  }
}

but the blow query returns nothing

{
  "query": {
    "bool": {
      "must": [
        {
          "wildcard": {
            "booking.cparty1": {
              "wildcard": "MANITOBA*",
              "boost": 1
            }
          }
        }
      ],
      "disable_coord": false,
      "adjust_pure_negative": true,
      "boost": 1
    }
  }
}
``````````````````

my mapping file:
`````````````````````
{
	"state": "open",
	"settings": {
		"index": {
			"mapping": {
				"total_fields": {
					"limit": "2000"
				}
			},
			"number_of_shards": "5",
			"provided_name": "trades_dpm_slave",
			"creation_date": "1514560558202",
			"number_of_replicas": "1",
			"uuid": "6Oq5mbLzTGOaPFE05ogg_A",
			"version": {
				"created": "5060499"
			}
		}
	},
	"mappings": {
		"trade": {
			"_all": {
				"enabled": false
			},
			"properties": {
				"booking": {
					"properties": {
						"bookrunnerUpdate": {
							"type": "date"
						},
						"linkedID": {
							"type": "text",
							"fields": {
								"keyword": {
									"type": "keyword",
									"doc_values": false
								}
							}
						},
						"parent": {
							"type": "text",
							"fields": {
								"keyword": {
									"type": "keyword",
									"doc_values": false
								}
							}
						},
						"bookRunnerUpdateTime": {
							"type": "date"
						},
						"confirmationType": {
							"include_in_all": true,
							"type": "text",
							"fields": {
								"keyword": {
									"type": "keyword",
									"doc_values": false
								}
							}
						},
						"book": {
							"include_in_all": true,
							"type": "text",
							"fields": {
								"keyword": {
									"type": "keyword",
									"doc_values": false
								}
							}
						},
						"dealerIDUpdate": {
							"type": "date"
						},
						"notepad": {
							"index": false,
							"type": "text"
						},
						"bookrunner": {
							"index": false,
							"type": "text"
						},
						"bookingPurpose": {
							"index": false,
							"type": "text"
						},
						"createdOn": {
							"type": "date"
						},
						"originated": {
							"type": "text",
							"fields": {
								"keyword": {
									"type": "keyword"
								}
							}
						},
						"notionalMatch": {
							"type": "boolean"
						},
						"dealRevenue": {
							"type": "text"
						},
						"dealerUpdateTime": {
							"type": "date"
						},
						"cparty1": {
							"include_in_all": true,
							"type": "text",
							"fields": {
								"keyword": {
									"type": "keyword"
								}
							}
						},
						"notionalTrade": {
							"type": "boolean"
						},
						"cparty2": {
							"type": "text",
							"fields": {
								"keyword": {
									"type": "keyword"
								}
							}
						},
						"id": {
							"include_in_all": true,
							"fielddata": true,
							"boost": 2,
							"type": "text",
							"fields": {
								"keyword": {
									"type": "keyword"
								}
							}
						},
						"terminated": {
							"type": "text"
						},
						"ticket": {
							"include_in_all": true,
							"boost": 2,
							"type": "text",
							"fields": {
								"keyword": {
									"type": "keyword"
								}
							}
						},
						"bookingSubPurpose": {
							"type": "text"
						},
						"executedOn": {
							"type": "date"
						},
						"transProductID": {
							"include_in_all": true,
							"type": "keyword"
						},
						"inceptionCVA": {
							"type": "text"
						},
						"tradeDate": {
							"type": "date"
						},
						"dealType": {
							"include_in_all": true,
							"type": "keyword"
						},
						"version": {
							"type": "short"
						},
						"createdBy": {
							"type": "keyword"
						},
						"affirmStatus": {
							"type": "keyword"
						},
						"name": {
							"type": "text",
							"fields": {
								"keyword": {
									"type": "keyword"
								}
							}
						},
						"folderName": {
							"include_in_all": true,
							"type": "text",
							"fields": {
								"keyword": {
									"type": "keyword"
								}
							}
						},
						"marketerId": {
							"include_in_all": true,
							"type": "text",
							"fields": {
								"keyword": {
									"type": "keyword"
								}
							}
						},
						"confirmationID": {
							"include_in_all": true,
							"type": "text",
							"fields": {
								"keyword": {
									"type": "keyword"
								}
							}
						},
						"entity": {
							"type": "text",
							"fields": {
								"keyword": {
									"type": "keyword"
								}
							}
						},
						"status": {
							"include_in_all": true,
							"type": "keyword"
						}
					}
				},
				"_default_": {
					"_all": {
						"enabled": false
					}
				}
			}
		}
	}
}

(David Pilato) #2

Please format your code using </> icon as explained in this guide and not the citation button. It will make your post more readable.

Or use markdown style like:

```
CODE
```

Please edit your post.

Here most likely you need to search with:

"wildcard": "manitoba*"

or search on booking.cparty1.keyword field.


(Derrick) #3

Dadoonet,

I cannot search with

"wildcard": "MANITOBA*"

WHY?


(David Pilato) #4

As per https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-wildcard-query.html

Matches documents that have fields matching a wildcard expression (not analyzed).

Read also:

Note that this query can be slow, as it needs to iterate over many terms. In order to prevent extremely slow wildcard queries, a wildcard term should not start with one of the wildcards * or ?.


(system) #5

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