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

How to build this query ? #336

Open
khanof89 opened this issue Aug 29, 2020 · 0 comments
Open

How to build this query ? #336

khanof89 opened this issue Aug 29, 2020 · 0 comments

Comments

@khanof89
Copy link

I really wanted to sort this out on my own but couldn't get it working in last 2 hours so asking for help, I need to create the following query:

{
"query": {
"bool": {
  "should": [
    {
      "bool": {
        "must": [
          {
            "match": {
              "description": "head of marketing"
            }
          },
          {
            "match": {
              "has_email": 1
            }
          }
        ]
      }
    },
    {
      "bool": {
        "must": [
          {
            "match": {
              "description": "cmo"
            }
          },
          {
            "match": {
              "has_email": 1
            }
          }
        ]
      }
    }
  ]
}
}
}

this is what I have done, but its not getting the required result:

$search = new Search();
    $descriptionMatch = new MatchQuery('description', 'head of marketing');
    $emailMatch = new MatchQuery('has_email', 1);
    $search->addQuery($descriptionMatch, BoolQuery::MUST);
    $search->addQuery($emailMatch, BoolQuery::MUST);

    return $search->toArray();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant