I am an ElasticSearch noob and I am trying to figure out how to boost the relevancy of search results that contain search terms in the "title" field. So for example, if there are two documents:
Title="Test Form" Description="This is a new form"
Title="New Form" Description="Test test test"
And the user searches for "test" across all fields, document 1 should get boosted since the search term appears in the title field.
I have attempted to follow the documentation here, but I am not sure about the context of where I should include that command. Is it applied to an index or a search or either? Does it need to be part of another element, or can it be issued as an individual command?
Here is what I have done so far, 5 documents are indexed, then the boost is applied and finally, a search is performed for the string "test" across all fields.
PUT http://localhost:9200//global/Form/456
{
"KeyWords": "",
"OneLineDesc": "Test",
"Link": "",
"Title": "Test Form"
}
PUT http://localhost:9200//global/Form/457
{
"KeyWords": "",
"OneLineDesc": "",
"Link": "",
"Title": "Another Form"
}
PUT http://localhost:9200//global/Form/458
{
"KeyWords": "",
"OneLineDesc": "test form",
"Link": "",
"Title": "Ryans Form"
}
PUT http://localhost:9200//global/Form/460
{
"KeyWords": "",
"OneLineDesc": "",
"Link": "",
"Title": "permissions test"
}
PUT http://localhost:9200//global/Form/576
{
"KeyWords": "",
"OneLineDesc": "Test test test test test test test test",
"Link": "",
"Title": "My Test Form"
}
POST http://localhost:9200//global/Form
{
"_boost": {
"name": "Title",
"null_value": 20
}
}
POST http://localhost:9200/_search?search_type=query_then_fetch
{
"from": 0,
"size": 10,
"query": {
"match": {
"_all": {
"query": "test"
}
}
}
}
However, the scores in the results are identical whether or not the boost command is issued after indexing.
I would prefer to perform this boosting operation during indexing because the title field will be considered more important than other fields across all documents. Also, in the example above the fields are constant for each document, but in general this will not be the case, though all documents will always have a title field. Each search needs to be should be performed over all available fields.