Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):
Opensearch-2.4.1
Server -CentOs7
Describe the issue:
We have created index as 2(integer not any String value).
We have below sample documents in OpenSearch repository-
Doc-1==========================
{
“_index”: “2”,
“_id”: “1411”,
“_score”: 1.0,
“_source”: {
“type”: “ITEM”,
“companyName”: “test1”,
“containerName”: “catalog”,
“identifier”: “1411”,
“primaryKey”: “cat4item1”,
“displayName”: “www”,
“attributes”: {
“cat_specs”: {
“item_id”: “cat4item1”,
“item_name”: “www”,
“item_description”: null,
“item_exp_date”: null,
“item price”: 2000.0,
“Reference Field”: {}
}
},
“mappings”: {
“hier”: [
“cat4”
]
},
“versionNumber”: 4
}
}
Doc-2===============================================
{
“_index”: “2”,
“_id”: “1411”,
“_score”: 1.0,
“_source”: {
“type”: “ITEM”,
“companyName”: “test1”,
“containerName”: “catalog”,
“identifier”: “1411”,
“primaryKey”: “cat4item1”,
“displayName”: “www”,
“attributes”: {
“cat_specs”: {
“item_id”: “cat4item1”,
“item_name”: “www”,
“item_description”: null,
“item_exp_date”: null,
“item price”: 2000.0,
“Reference Field”: {}
}
},
“mappings”: {
“hier”: [
“cat4”
]
},
"versionNumber": 4
}
}
We need to find the records/documents which does not follow certain condition -
HTTP METHOD: POST
URL:/_plugins/_sql
Body:
{“query”:“SELECT count(*) FROM `2` WHERE companyName = ‘test1’ AND containerName = ‘catalog’ AND NOT ((((`attributes.cat_specs.item_id` IS NOT NULL) AND (`attributes.cat_specs.item price` = 2000))))”,
“fetch_size”:100
}
Observation: if index is integer, then we need to apply the backtick to make it STRING.
We had to use back tick (`) as one of the document attribute (item price) is having space between attribute name.
The query does not work if fetch_size is added to query like given above-
Please suggest if any modification needed in query
Configuration:
Relevant Logs or Screenshots: