Legend:
' is the quotation mark for the better reading of each string value.
(star) is *
string values like 'Karlsruhe-Durlach', 'Karlsruhe', 'Karlsruhe)Südstadt' and 'München' are stored in elastic search.
My problem:
A search string like '(star)ruhe-Durl(star)' should be matched with the stored string 'Karlsruhe-Durlach'.
My idea was:
GET _search
{
"query": {
"query_string": {
"query": "*ruhe-Durl*"
}
}
}
=> No result
If the string '"Karlsruhe-Durlach"' is searched:
GET _search
{
"query": {
"query_string": {
"query": "\"Karlsruhe-Durlach\""
}
}
}
=> 'Karlsruhe-Durlach' will be the result.
If the string '(star)"rlsruhe-Durlac"(star)' is searched:
GET _search
{
"query": {
"query_string": {
"query": "*\"rlsruhe-Durlac\"*",
"default_field" : "city"
}
}
}
=> 'Karlsruhe-Durlach', 'Karlsruhe', 'Karlsruhe)Südstadt' and 'München' will be the result.
If the string '(star)urlac(star)' is searched:
GET _search
{
"query": {
"query_string": {
"query": "*urlac*"
}
}
}
=> 'Karlsruhe-Durlach' will be the result.
The index was created as follows:
{
"settings":{
"index":{
"analysis":{
"analyzer":{
"german":{
"tokenizer":"keyword",
"filter":"standard"
}
}
}
}
},
"mappings":{
"organization":{
"properties":{
"id":{
"analyzer": "german",
"index": "not_analyzed",
"type":"string"
}
}
}
}
}
How should the infix search string with hyphen be written? A infix search string like '(star)ruhe-Durl(star)' should be matched only with 'Karlsruhe-Durlach'. Is there an error at the infix search string or at the index creation?