Hi,
I am creating a search query in which I am searching course name. For example if I search "Introduction to R" then the output is "Introduction to Scrum". In this query "R" is not considered as a single word while searching document.
I have attached the query for reference.
{
"_source": [
"meta_title",
"meta_description",
"general_title",
"provider_logo"
],
"query": {
"bool": {
"must": [
{
"bool": {
"should": [
{
"multi_match": {
"type": "best_fields",
"fields": [
"meta_title",
"meta_description",
"general_title",
"provider_logo"
],
"operator": "and",
"query": "Introduction to r",
"boost": 1
}
},
{
"query_string": {
"query": "Introduction to r",
"fields": [
"category_link",
"course_link"
]
}
}
]
}
}
],
"should": [
{
"multi_match": {
"type": "best_fields",
"fields": [
"meta_title^10",
"meta_description",
"general_title",
"provider_logo"
],
"operator": "AND",
"query": "Introduction to r",
"boost": 20
}
},
{
"multi_match": {
"type": "best_fields",
"fields": [
"meta_title^10",
"meta_description",
"general_title",
"provider_logo"
],
"operator": "OR",
"query": "Introduction to r",
"boost": 10
}
},
{
"query_string": {
"query": "Introduction to r",
"fields": [
"category_link",
"course_link"
],
"boost": 10
}
}
]
}
},
"aggs": {
"top-providers": {
"terms": {
"field": "provider_name",
"order": {
"top_hit": "desc"
}
},
"aggs": {
"top-categories_hits": {
"top_hits": {
"_source": {
"excludes": [
"brief_html"
]
}
}
},
"top_hit": {
"max": {
"script": {
"source": "_score"
}
}
}
}
}
}
}