Hi,
Here is my index with settings and mappings
curl -XPUT 'http://localhost:9200/special_index' -d '{
"settings": {
"numberOfShards": "5",
"numberOfReplicas": "1",
"analysis": {
"filter": {
"edge_ngram_filter": {
"type": "edge_ngram",
"min_gram": "1",
"max_gram": "100",
"token_chars": [
"letter"
]
},
"word_delimiter_for_phone": {
"type": "word_delimiter",
"catenate_all": true,
"generate_number_parts ": false,
"split_on_case_change": false,
"generate_word_parts": false,
"split_on_numerics": false,
"preserve_original": true
}
},
"analyzer": {
"edge_ngram_analyzer": {
"type": "custom",
"filter": [
"lowercase",
"edge_ngram_filter",
"word_delimiter_for_phone"
],
"tokenizer": "whitespace"
},
"case_insensitive_sort_analyzer": {
"type": "custom",
"tokenizer": "keyword",
"filter": [
"lowercase"
]
}
}
}
},
"mappings": {
"documents": {
"properties": {
"id": {
"type": "string",
"index_analyzer": "edge_ngram_analyzer",
"search_analyzer": "standard",
"fields": {
"sort": {
"type": "string",
"analyzer": "case_insensitive_sort_analyzer"
}
}
},
"name": {
"type": "string",
"index_analyzer": "edge_ngram_analyzer",
"search_analyzer": "standard",
"fields": {
"sort": {
"type": "string",
"analyzer": "case_insensitive_sort_analyzer"
}
}
}
}
}
}
}'
Now inserted the below documents
curl -XPUT 'http://localhost:9200/special_index/documents/1' -d '{ "id": "101", "name": "abcd" }'
curl -XPUT 'http://localhost:9200/special_index/documents/2' -d '{ "id": "102", "name": "abc" }'
curl -XPUT 'http://localhost:9200/special_index/documents/3' -d '{ "id": "103", "name": "@#$%" }'
curl -XPUT 'http://localhost:9200/special_index/documents/4' -d '{ "id": "104", "name": "@#$%" }'
curl -XPUT 'http://localhost:9200/special_index/documents/5' -d '{ "id": "104", "name": "@#$%xyz" }'
When I search for name containing only alphabets and alphabets + special characters using elasticsearch query dsl it works.
curl -XGET 'http://localhost:9200/special_index/documents/_search?pretty' -d '{"query":{"query_string":{ "query": "name:@#$%xyz"}}}'
curl -XGET 'http://localhost:9200/special_index/documents/_search?pretty' -d '{"query":{"query_string":{ "query": "name:abcd"}}}'
But when I search for text containing only special characters it does not work. Kindly advise how to search for text containing only special characters.
curl -XGET 'http://localhost:9200/special_index/documents/_search?pretty' -d '{"query":{"query_string":{ "query": "name:@#$%"}}}'
Thanks in Advance,
Abhishek