I am not able to search URL's which contains special characters like http://example.sample.com/guide/Analyzers_Terms_and_Analysis_(ABC)_Guide
Suppose I have indexed 4 noteText
-
http://example.sample.com/guide/Analyzers_Terms_and_Analysis_%28ABC%29_Guide
-
example
-
Terms
-
Analysis
Expected Result - When I search with full URL option (1) it should output me the exact result of URL only and not with partial search with other indexed values like example
, Terms
, Analysis
.
Index Settings -
PUT my_index
{
"settings": {
"index": {
"analysis": {
"filter": {
"my_ngram": {
"type": "nGram",
"min_gram": 1,
"max_gram": 50
}
},
"char_filter": {
"whitespace_mapping": {
"mappings": [
"\\u00A0=>\\u0020"
],
"type": "mapping"
}
},
"analyzer": {
"default": {
"type": "custom",
"char_filter": [
"whitespace_mapping"
],
"filter": [
"lowercase",
"asciifolding",
"stop",
"my_ngram",
"kstem"
],
"tokenizer": "whitespace"
},
"default_search": {
"type": "custom",
"char_filter": [
"whitespace_mapping"
],
"filter": [
"lowercase",
"asciifolding",
"kstem"
],
"tokenizer": "whitespace"
},
"match_phrase": {
"type": "custom",
"char_filter": [
"whitespace_mapping"
],
"filter": [
"lowercase"
],
"tokenizer": "whitespace"
},
"match_phrase_search": {
"type": "custom",
"char_filter": [
"whitespace_mapping"
],
"filter": [
"lowercase",
"stop"
],
"tokenizer": "whitespace"
}
}
}
}
}
}
Mapping -
PUT my_index/_mapping/notes
{
"properties": {
"userId": {
"type": "long"
},
"noteText": {
"analyzer": "match_phrase",
"term_vector": "with_positions_offsets",
"type": "text",
"fields": {
"ngrammed": {
"term_vector": "with_positions_offsets",
"type": "text"
}
}
}
}
}
Search Query -
POST /my_index/_search
{
"query": {
"bool": {
"must": [
{
"constant_score": {
"query": {
"query_string": {
"query": "http://example.sample.com/guide/Analyzers_Terms_and_Analysis_%28ABC%29_Guide",
"fields": [
"noteText.ngrammed"
],
"analyzer": "match_phrase_search"
}
},
"boost": 5
}
},
{
"query_string": {
"query": "http://example.sample.com/guide/Analyzers_Terms_and_Analysis_%28ABC%29_Guide",
"fields": [
"noteText.ngrammed"
]
}
}
]
}
}
}