TL;DR: I want to find documents that match a certain query (e.g. "my search") OR match the unique ID of a document.
When I search for the text field alone, the search is super fast. However, when I or the text field with the keyword field search becomes extremely slow. Looking at the profile data, it seems like the shard that contains the document ends up doing a lot more next_doc
than the other shards. Why would that be the case?
Below are the mappings and queries I executed for reference.
Mapping:
{
"mappings": {
"properties": {
"searchable_name_1": { "type": "text" },
"searchable_name_2": { "type": "text" },
"unique_identifier": { "type": "keyword" }
}
}
}
The following query executes super fast:
{
"profile": true,
"query": {
"bool": {
"should": [
{
"multi_match": {
"query": "my search",
"fields": [
"searchable_name_1",
"searchable_name_2"
]
}
}
]
}
}
}
However, when I or the unique identifier with the text query, it becomes super slow:
{
"profile": true,
"query": {
"bool": {
"should": [
{
"multi_match": {
"query": "my search",
"fields": [
"searchable_name_1",
"searchable_name_2"
]
}
},
{
"term": {
"unique_identifier": {
"value": "13590585",
"boost": 10
}
}
}
]
}
}
}