I have Elasticsearch setup for searching book content. It works for the most part, however it frequently misses single search terms, especially in the 'entryTitle'. An example is in one book there is a Section title called "Parks and Recreation", however with the search term 'parks' it does not find it.
It also for my use case ideally should be prioritizing the results from the 'entryTitle' over the 'entryContent' results.
The current query is:
$params = [
'index' => 'toc_entries',
'type' => '_doc',
'body' => [
'min_score' => '0.1',
'sort' => [
'_score'
],
'_source' => [
'entryTitle',
'entryId'
],
'query' => [
'bool' => [
'filter' => [
'term' => [
'bookSku.raw' => $sku
]
],
'should' => [
[
'match' => [
'entryTitle' => [
'query' => $search_term,
'_name' => 'title'
]
]
],
[
'match' => [
'entryContent' => [
'query' => $search_term,
'_name' => 'body'
]
]
]
]
]
],
'highlight' => [
'pre_tags' => [''],
'post_tags' => [''],
'fields' => [
'entryContent' => new \stdClass(),
'entryTitle' => new \stdClass()
]
]
]
];
Can any Elasticsearch experts see where I have gone wrong here?
Thank you in advance
Edit:
Here is the structure of the setup:
{
"analysis":{
"analyzer":{
"default":{
"type":"english"
}
}
},
"settings":{
"number_of_shards":1,
"number_of_replicas":1
},
"mappings":{
"_default_":{
"dynamic":"strict"
},
"_doc":{
"properties":{
"bookSku":{
"type":"text",
"fields":{
"raw":{
"type":"keyword"
}
}
},
"entryId":{
"type":"text",
"fields":{
"raw":{
"type":"keyword"
}
}
},
"entryTitle":{
"type":"text"
},
"entryContent":{
"type":"text"
}
}
}
}
}