We did some tests using the copy_to functionality where all string values are copied into the custom "all_fields" field. Without using highlighting, any search is now much faster than before.
However, using highlighting, we still see a significant performance drop in searches with leading star wildcards.
This is an example of a search using highlighting and star wildcards:
{
"size": 20,
"sort": [
{
"lastUpdated": {
"order": "desc"
}
}
],
"highlight": {
"pre_tags": [
"<hl>"
],
"post_tags": [
"</hl>"
],
"number_of_fragments": 0,
"fields": {
"key": {
"type": "plain",
"highlight_query": {
"query_string": {
"query": "*sql*"
}
}
},
"severityIndex": {
"type": "plain",
"highlight_query": {
"query_string": {
"query": "*sql*"
}
}
},
"target": {
"type": "plain",
"highlight_query": {
"query_string": {
"query": "*sql*"
}
}
},
"name": {
"type": "plain",
"highlight_query": {
"query_string": {
"query": "*sql*"
}
}
},
"resolutionState": {
"type": "plain",
"highlight_query": {
"query_string": {
"query": "*sql*"
}
}
},
"lastUpdated": {
"type": "plain",
"highlight_query": {
"query_string": {
"query": "*sql*"
}
}
},
"sourceType": {
"type": "plain",
"highlight_query": {
"query_string": {
"query": "*sql*"
}
}
},
"source.scom.monitoringObjectPath": {
"type": "plain",
"highlight_query": {
"query_string": {
"query": "*sql*"
}
}
}
},
"require_field_match": false
},
"_source": {
"includes": [
"key",
"severityIndex",
"target",
"name",
"resolutionState",
"lastUpdated",
"sourceType",
"source.scom.monitoringObjectPath"
]
},
"query": {
"bool": {
"must": [
{
"query_string": {
"query": "*sql*",
"fields": [
"all_fields"
]
}
}
],
"filter": [
{
"bool": {
"must": [
{
"match_all": {}
},
{
"match_all": {}
},
{
"match_all": {}
},
{
"match_all": {}
}
]
}
}
]
}
}
}
As you can see, we used the Plain highlighter instead of the default highlighter, as it seems to perform better in our case.