Created
January 18, 2017 12:06
-
-
Save GyllingSW/0a7d85702916c2b5a19d7dcc3f7eca4c to your computer and use it in GitHub Desktop.
Elasticsearch highlights deep nested using danish analyzer - not working as expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Steps to reproduce using sence or kibana dev tools | |
# | |
PUT /test_index | |
{ | |
"settings": { | |
"number_of_shards": 1, | |
"number_of_replicas": 0 | |
}, | |
"mappings" : { | |
"file" : { | |
"properties" : { | |
"text" : { | |
"type" : "string", | |
"analyzer": "danish" | |
}, | |
"level_two_text" : { | |
"type": "nested", | |
"properties": { | |
"text" : { | |
"type": "string", | |
"analyzer": "danish" | |
} | |
} | |
}, | |
"level_three_text": { | |
"type": "nested", | |
"properties": { | |
"level_two": { | |
"type": "nested", | |
"properties": { | |
"text": { | |
"type": "string", | |
"analyzer": "danish" | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
# Works as expected | |
POST /test_index/file | |
{ | |
"text" : "Text around a name Jensen, Hans and finding the name", | |
"level_two_text" : { | |
"text" : "Text around a name Jensen, Anders and finding the name" | |
}, | |
"level_three_text" : { | |
"level_two" : { | |
"text" : "Text around a name Hans Jensen and finding the name" | |
} | |
} | |
} | |
# Works as expected | |
POST /test_index/file/_search | |
{ | |
"query": { | |
"nested": { | |
"path": "level_two_text", | |
"query": { | |
"query_string": { | |
"default_field": "level_two_text.text", | |
"query": "\"Jensen, Anders\"" | |
} | |
}, | |
"inner_hits" : { | |
"highlight" : { | |
"fields" : { | |
"level_two_text.text" : { | |
"number_of_fragments": 0 | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
# Does not work as expected - but works if using the english analyzer instead of the danish | |
POST /test_index/file/_search | |
{ | |
"query": { | |
"nested": { | |
"path": "level_three_text.level_two", | |
"query": { | |
"query_string": { | |
"default_field": "level_three_text.level_two.text", | |
"query": "\"Hans Jensen\"" | |
} | |
}, | |
"inner_hits" : { | |
"highlight" : { | |
"fields" : { | |
"level_three_text.level_two.text" : { | |
"number_of_fragments": 0 | |
} | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment