Hi,
I want to preserve the special characters like -, /, (, ) in search results.
Ex: Abc/def a(bc)def a-bcd
response: If I enter Abc/ the records containing abc/ need to come, similarly for abc/def records with the following need to come, in the same way abc/def a(bc) records with the similar combination need to come.
For this I have used different analyzers and filters and the settings and mappings as follows:
PUT /facebook?pretty=true
{
"settings" : {
"analysis" : {
"filter" : {
"special_character_spliter" : {
"type" : "word_delimiter",
"preserve_original": "true"
}
},
"analyzer" : {
"my_an" : {
"type" : "pattern",
"pattern" : "[^(/-*\w\p{L}]+",
"tokenizer" : "whitespace",
"filter" : [ "special_character_spliter"]
}
}
}
},
"mappings" : {
"face" : {
"properties" : {
"msg" : {
"type" : "string",
"analyzer": "my_an"
},
"name" : {
"type" : "string"
}
}
}
}
}
and even I have tried with the following settings also:
PUT facebook?pretty=true
{
"settings": {
"index.number_of_replicas": 0,
"analysis": {
"analyzer": {
"msg_excp_analyzer": {
"type": "custom",
"tokenizer": "whitespace",
"filters": ["my_word_delimiter","my_word_pattern",
"lowercase",
"asciifolding",
"shingle",
"standard"]
}
},
"filters": {
"my_word_pattern":
{
"type" : "pattern_capture",
"preserve_original" : 1,
"patterns" : [
"(\w+)",
"(\p{L}+)",
"(\d+)",
"@(.+)"
]
},
"my_word_delimiter": {
"type": "word_delimiter",
"preserve_original": "true",
"catenate_all": "true",
"type_table": {
"$": "DIGIT",
"%": "DIGIT",
".": "DIGIT",
",": "DIGIT",
":": "DIGIT",
"/": "DIGIT",
"\\": "DIGIT",
"=": "DIGIT",
"&": "DIGIT",
"(": "DIGIT",
")": "DIGIT",
"<": "DIGIT",
">": "DIGIT",
"\\U+000A": "DIGIT"
},
"my_asciifolding": {
"type": "asciifolding",
"preserve_original": true
}
}
}
}
},
"mappings": {
"face": {
"properties": {
"msg": {
"type": "string",
"index": "analyzed",
"analyzer": "msg_excp_analyzer"
},
"name": {
"type": "string",
"index": "analyzed",
"analyzer": "msg_excp_analyzer"
}
}
}
}
}
With above settings I have tried separately inorder to preserve the special characters in search results,
and i have used query like:
GET facebook/face/_search
{
"query": {
"bool": {
"must": [
{
"query_string": {
"fields": [
"msg"
],
"query": "a/"
}
}
]
}
}
}
Am getting the following error:
"error": "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[trVZmtb4Qu-QWIqxK5hEfg][facebook][0]: SearchParseException[[facebook][0]:
May I know what is the problem with , whether is it with my query or settings?