Hello,
As a newbie, I'm trying to build a compound query for my NodeJS/Express web app. All I need is to give priority to phrases first in the search results if they exist... For example let's search for "customers are" phrase. Results should look like that:
- Our customers are resilient.
- It is always our intention that customers are satisfied with everything they buy from us.
- Customers who are served well become repeat customers who purchase more.
- Increasing number of customers who give a five star review are brilliant!
Seems like my bool query works well to achieve the results above. Here is my query:
{
bool: {
must: {
match: {
sentence: {
query: 'customers are',
fuzziness: 'AUTO',
operator: 'AND',
},
},
},
should: {
match_phrase_prefix: {
sentence: {
query: 'customers are',
},
},
},
},
}
I want to add more searching features for my app.
A) When users search for "cusotmers are" instead of "customers are" with a simple typo, results look weird. For example:
- Once you’ve claimed your new-customer offer, there are plenty of brilliant existing promotions available which are available for all existing customers of Apple.
- New Customer Promo are giving new customers a fantastic offer for the NBA playoffs.
- Improve home security for cheaper insurance! Customers are more likely to get cheap home insurance if a provider considers them a ‘low-risk customer’.
(like you see, the 3rd result should actually have became the first result).
B) If there is no any a lot of "customers" keywords, it should also search for "customer" instead (Please check the 5th result below).
- Our customers are resilient.
- It is always our intention that customers are satisfied with everything they buy from us.
- Customers who are served well become repeat customers who purchase more.
- Increasing number of customers who give a five star review are brilliant!
- Most customer are expected to see their power restored by midnight.
Or if users search for "got tired", results related to "got tired" should appear first. And then other variations of the verb should appear. So, For example if there are no a lot of phrases starting with "got tired", then "get tired" should appear:
- He may have got tired of Hollywood.
- I might get tired of one and then I'll rotate to the next.
- ...
Thank you in advance!
Kind regards,
Serdar