Hi
I created a test_index and sharing the details
PUT test_index/1/101
{
"title": "LR-123QZE",
"description": "LR-123QZE description"
}
PUT test_index/1/102
{
"title": "Lr-124QZE",
"description": "Lr-124QZE description"
}
PUT test_index/1/103
{
"title": "lr-125QZE",
"description": "lr-125QZE description"
}
PUT test_index/1/104
{
"title": "LR-123QZE",
"description": "LR 126QZE description"
}
PUT test_index/1/105
{
"title": "LR-123QZE",
"description": "lr 123QZE description"
}
PUT test_index/1/106
{
"title": "ID/123WDER",
"description": "ID/123WDER description"
}
GET test_index/_search
{
"query": {
"bool": {
"must": {
"query_string": {
"query":"*lr-*", ///comment: "query":"*LR-*" or "query":"*lr\\-*", or "query":"*LR\\-*",
"fields": ["title","description"]
}
}
}
}
}
result:
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
expected result:
"hits": [
{
"_index": "test_index",
"_type": "1",
"_id": "101",
"_score": 1,
"_source": {
"title": "LR-123QZE",
"description": "LR-123QZE description"
}
},
{
"_index": "test_index",
"_type": "1",
"_id": "103",
"_score": 1,
"_source": {
"title": "lr-125QZE",
"description": "lr-125QZE description"
}
},
{
"_index": "test_index",
"_type": "1",
"_id": "104",
"_score": 1,
"_source": {
"title": "LR-123QZE",
"description": "LR 126QZE description"
}
},
{
"_index": "test_index",
"_type": "1",
"_id": "102",
"_score": 1,
"_source": {
"title": "Lr-124QZE",
"description": "Lr-124QZE description"
}
}
]
}
Query:
GET test_index/_search
{
"query": {
"bool": {
"must": {
"query_string": {
"query":"*ID/*",
"fields": ["title","description"]
}
}
}
}
}
result: error
{
"error": {
"root_cause": [
{
"type": "query_shard_exception",
"reason": "Failed to parse query [*ID/*]",
"index_uuid": "aXYtffzVTFeQsxtxEDyGgg",
"index": "test_index"
}
]
expected result:error
Query
GET test_index/_search
{
"query": {
"bool": {
"must": {
"query_string": {
"query":"*ID\\/*",
"fields": ["title","description"]
}
}
}
}
}
result:
"hits": {
"total": 0,
"max_score": null,
"hits": [\*]
}
``````
expected result:
"hits": {
"total": 1,
"max_score": 1,
"hits": [
{
"_index": "test_index",
"_type": "1",
"_id": "106",
"_score": 1,
"_source": {
"title": "ID/123WDER",
"description": "ID/123WDER description"
}
}
]
}
mapping details
{
"test_index": {
"mappings": {
"1": {
"properties": {
"description": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"title": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
}
Regards,
Shyam