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

Allow custom queries in painless scripting language #1748

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

scottbuckel
Copy link

This allows the user to write a custom query in the painless scripting language https://www.elastic.co/guide/en/elasticsearch/painless/current/index.html.

For example, to search for a post by meta.birthday for all people born in March, you can use the following code:

$args['custom_query'][] = "doc['meta.birthday'].value.getMonthValue() == 3";

@tlovett1
Copy link
Member

@sebumd this is interesting. Assuming it works and @tott and @brandwaffle, are okay with it. I think we can add this. However, first please run your PR through PHPCS as there are some issues.

@scottbuckel
Copy link
Author

@tlovett1 thanks! I fixed the PHPCS issue.

@tott @brandwaffle what's the process to get this tested, approved and released for ElasticPress? Right now I'm using a hacked version of the module in production and would like to be able to include this feature and update to the latest when it comes out.

@jeffpaul jeffpaul added this to the 3.5.2 milestone Dec 18, 2020
@brandwaffle brandwaffle modified the milestones: 3.5.2, 3.6.0 Jan 18, 2021
@Rahmon
Copy link
Contributor

Rahmon commented Mar 1, 2021

Hi @sebumd.

I would like to review this PR. Could you provide more information to test it? I've tried but looks like the filter is not applied.

@scottbuckel
Copy link
Author

@Rahmon This is how I'm using it myself:

 if (isset($_GET['birthDateYear']) && !empty($_GET['birthDateYear'])) {
    $birthDateYear = esc_html($_GET['birthDateYear']);
    $args['custom_query'][] = "doc['meta.birthdate.date'].value.getYear() == " . $birthDateYear;
}

@mckdemps mckdemps removed this from the 3.6.0 milestone Jun 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants