Not able to search data when doing like searching with special character

Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):

Hello Team,

I used Helm charts to set up a multi-node open search cluster, and I entered all of my data into my open-search index. However, when I tried to search for specific characters or conditions using expressions, I was unable to find the data I was looking for in open-search.

In reality, I would like to search data using special characters, but when I do so, I receive nothing.
Please let me know under what circumstances I receive data and when I do not.

Ex: Consider name as below

Test Yes
Test_ No
Test - No
test-01 No
Testabc - yes
Test@ No

Note:

  1. Apart from that any special character is came then also will not get any data as well if will search with 01 then will get test-01, test-02.
  2. When I was search with Test 1 then will get test 01, test 02, test 03, test 1. but I want only test 1 which is exactly matched or test 11.
    I am using criteria org.springframework.data.elasticsearch.core.query.Criteria and ElasticSarchOperation [org.springframework.data.elasticsearch.core] bulkindex api’s to get the data from open search .

Using criteria as below:

Criteria orCriteria = new Criteria(field).expression(““+globalSearch+””);

Index setting is :

{“indexname”:{“settings”:{“index”:{“refresh_interval”:“1s”,“number_of_shards”:“1”,“provided_name”:“indexname”,“creation_date”:“1707817341888”,“store”:{“type”:“fs”},“number_of_replicas”:“1”,“uuid”:“abc”,“version”:{“created”:“136287827”}}}}}

Index mapping is :

{“indexname”:{“mappings”:{“properties”:{“_class”:{“type”:“text”,“fields”:{“keyword”:{“type”:“keyword”,“ignore_above”:256}}},“name”:{“type”:“text”}

@opensearch @opensearch_user100 and Team Can you Please check and resolve my problem.

Describe the issue:

Configuration:

Relevant Logs or Screenshots:

Hi @ganeshsanpada

What version of OpenSearch do you use? Could you please share your mappings settings again? It seems, there are no enough right curly brackets.

Also, please try to execute in the DevTools the following search query with whitespace search analyzer:

GET your_index_name/_search
{
  "query": {
    "match": {
      "name": {
        "query": "Test@",
        "analyzer": "Whitespace"
      }
    }
  }
}

Hello @Eugene7 ,

Thanks for the update I have checked with whitespace analyser also but it seems not working please find the mapping where I have used whitespace analyser also please find version related details of open search.

curl -X GET “http://localhost:9200
{
“name” : “afdaf6deeada”,
“cluster_name” : “docker-cluster”,
“cluster_uuid” : “n5TaZxyiRSmFRAzRvnC_4A”,
“version” : {
“distribution” : “opensearch”,
“number” : “2.7.0”,
“build_type” : “tar”,
“build_hash” : “b7a6e09e492b1e965d827525f7863b366ef0e304”,
“build_date” : “2023-04-27T21:44:48.068301228Z”,
“build_snapshot” : false,
“lucene_version” : “9.5.0”,
“minimum_wire_compatibility_version” : “7.10.0”,
“minimum_index_compatibility_version” : “7.0.0”
},
“tagline” : “The OpenSearch Project: https://opensearch.org/
}

#Mappings

{“projecttask”:{“mappings”:{“properties”:{“actionVisibleOn”:{“type”:“text”},“actualEndTime”:{“type”:“date”,“format”:“date_time”},“actualStartTime”:{“type”:“date”,“format”:“date_time”},“apiContext”:{“type”:“text”},“apiJson”:{“type”:“text”},“apiMessage”:{“type”:“text”},“apiUrl”:{“type”:“text”},“assignee”:{“type”:“text”},“assigneeType”:{“type”:“text”},“autoComplete”:{“type”:“text”}“createdTime”:{“type”:“date”,“format”:“date_time”},“creator”:{“type”:“text”},“creatorId”:{“type”:“integer”},“currentOwner”:{“type”:“text”},“customApiToCall”:{“type”:“boolean”},“email”:{“type”:“text”},“entityGeographyL2Name”:{“type”:“text”},“entityGeographyL3Name”:{“type”:“text”,“analyzer”:“whitespace_analyzer”}}}}}

Please note that I am using below code to get the data from open-search along with that there are multiple conditions and criteria for diff diff fields filters::

    Criteria orCriteria = new Criteria(field).expression(globalSearch+"*");
    orCriteria = orCriteria.and(criteria);
     operations.search(searchQuery, ProjectTaskOpenSearchWrapper.class,           IndexCoordinates.of(PROJECT_TASK_INDEX));
      int upper = Math.min(upperLimit, projectTaskSolrWrapperSearchHits.getSearchHits().size());

Note: In my db I have data with “generatedNumber”: “RFFN-51-1643619437868” in my index doc

but when I was search with “globalSearchOS”:“RFFN-51” then I will get the desired result but when I will search with “globalSearchOS”:“RFFN-51-” then I will get empty result.

Please provide me the solution will waiting for your solution.