0

This works:

 GET /bitbucket$$pull-request-activity/_search
 {
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "prid": "12343"
          }
        },
        {
          "match": {
            "repoSlug": "com.xxx.vserver"
          }
        }
      ]
    }
  }
}

But I would like to capture multiple prids in one call. This does not work however:

 GET /bitbucket$$pull-request-activity/_search


{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "prid": "[12343, 11234, 13421]"
          }
        },
        {
          "match": {
            "repoSlug": "com.xxx.vserver"
          }
        }
      ]
    }
  }
}

any hints?

1 Answer 1

1

As you are using must in your bool query, then this represents logical AND, so be sure that all the documents that you are Matching of the prid field, should also match with "repoSlug": "com.xxx.vserver".

If none of the documents match with "repoSlug": "com.xxx.vserver", then no result will return.

And, if only 2 documents match, then only 2 of them will be returned in the search result, and not all the documents.

Adding Working example with mapping, sample docs and search query

Index Sample Data :

{
  "id":"1",
  "message":"hello"
}
{
  "id":"2",
  "message":"hello"
}
{
  "id":"3",
  "message":"hello-bye"
}

Search Query:

{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "id": "[1, 2, 3]"
          }
        },
        {
          "match": {
            "message": "hello"
          }
        }
      ]
    }
  }
}

Search Result :

"hits": [
      {
        "_index": "foo14",
        "_type": "_doc",
        "_id": "1",
        "_score": 1.5924306,
        "_source": {
          "id": "1",
          "message": "hello"
        }
      },
      {
        "_index": "foo14",
        "_type": "_doc",
        "_id": "3",
        "_score": 1.4903541,
        "_source": {
          "id": "3",
          "message": "hello-bye"
        }
      },
      {
        "_index": "foo14",
        "_type": "_doc",
        "_id": "2",
        "_score": 1.081605,
        "_source": {
          "id": "2",
          "message": "hello"
        }
      }
    ]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.