(Elasticsearch 5.2.2)
I'm having some trouble getting highlighting to work correctly. My mapping has 2 custom created _all-fields myall1 and myall2 that are created via copy_to:
"mytype": {
"_all": {
"enabled": false
},
"properties": {
"myall": {
"type": "text",
"analyzer": "standard",
"store": true
},
"myall2": {
"type": "text",
"analyzer": "standard",
"store": true
},
"field1": {
"type": "text",
"copy_to": "myall1",
"analyzer": "keyword"
},
"field2": {
"type": "text",
"copy_to": "myall2",
"analyzer": "keyword"
}
}
A document would look like this:
{
"field1": "example text",
"field2": "another text"
}
Now I'm running a multi_match-query that boosts myall1 by 3:
POST /myindex/mytype/_search
{
"query": {
"bool": {
"must": {
"multi_match": {
"fields": ["myall1^3", "myall2"],
"type": "cross_fields",
"query": "example text",
"operator": "and"
}
}
}
}
}
This works quite well. The problem is that I cannot highlight the original source-fields in the result. I'm adding the following to the query the same way it is done in the ES-docs "_all example":
,
"highlight": {
"pre_tags": ["<span class='highlight'>"],
"post_tags": ["</span>"],
"fields": {
"*": {"require_field_match": false}
}
}
This gives me only the highlighting in "myall1" and "myall2", NOT in the original fields "field1" and "field2".
If I do something similar by using the _all-field, everything works as expected. The main difference is: I'm using multi_match while the examples use query_string. Playing with "store":true and "analyzer":"standard" didn't help.
As my actual document uses nested-objects that must be searchable, I might not be able to do a completely different query-approach.
Is this by design or am I missing something? Using the "_all"-field instead would not allow me to boost results the way I'm trying to implement it.