Skip to content

Instantly share code, notes, and snippets.

@atakde
Created January 6, 2024 10:35
Show Gist options
  • Save atakde/53afdcc7b41997733d94ad32ff2a0f8e to your computer and use it in GitHub Desktop.
Save atakde/53afdcc7b41997733d94ad32ff2a0f8e to your computer and use it in GitHub Desktop.
Elastic Filter Example
<?php
$searchResults = $searchEngine->search(
[
'index' => 'search-linkedin-post', // index name
'_source' => 'public_linkedin_posts_new_text, public_linkedin_posts_new_poster_linkedin_url, public_linkedin_posts_new_reshared', // fields to return
'body' => [
'query' => [
'bool' => [
'filter' => [
'term' => ['public_linkedin_posts_new_reshared' => true] // filter by false
],
'should' => [
[ 'match' => [ 'public_linkedin_posts_new_text' => 'react' ] ],
[ 'match' => [ 'public_linkedin_posts_new_text' => 'php' ] ],
]
]
]
]
]
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment