Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Add ability to boost specific keywords #3534

Open
1 task done
oscarssanchez opened this issue Jul 5, 2023 · 2 comments
Open
1 task done

Enhancement: Add ability to boost specific keywords #3534

oscarssanchez opened this issue Jul 5, 2023 · 2 comments

Comments

@oscarssanchez
Copy link
Contributor

Is your enhancement related to a problem? Please describe.

We can weight specific fields but Elastic also gives you the chance to boost specific keywords via a query string query. See https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#_boosting

We would probably need to add this to the queries we set by default, and also think about scalability issues when adding keywords.

Designs

No response

Describe alternatives you've considered

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@felipeelia
Copy link
Member

I made some exploration on this one and it seems it is not possible to use boosting and function_score in the same query. For anyone wanting to continue the discovery, here is how far I went: https://gist.github.com/felipeelia/8fc76ae6e2eda6d69d8cc7f21086f6eb

@oscarssanchez
Copy link
Contributor Author

oscarssanchez commented Jul 7, 2023

An alternative could be using an additional should clause

add_filter( 'ep_formatted_args', function( $formatted_args, $args ) {
$formatted_args["query"]["function_score"]["query"]["bool"]["should"][3]["multi_match"]["fields"] = 'terms.category.name';
$formatted_args["query"]["function_score"]["query"]["bool"]["should"][3]["multi_match"]["query"] = 'myterm';

return $formatted_args;
}, 9999999, 2 );

If we make the enhancement this wouldn't go in the ep_formatted_args. We would probably need to work on limiting the available fields with this approach as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants