Bool OR term quey does not match any document

Hello guys,

I am trying to dive into DDD architecture by implement CQRS and event sourcing pattern into my app. The app is a simple blog api with article management and user authentication. I'm using elastic to store my events and the read model in order to rebuild the article when a change is done and keep track change on it. Kind of a google docs feature.

My stack is based on golang, I'm using go-elastic package for my api calls.(which is poorly documentated). I'm on a docker environment and everything's working well.

I have in elastic some documents referenced by a AggregateID on which I want to make exact search in order to find all the associated events. Here's an example of a event document:

"_index": "article",
  "_type": "_doc",
  "_id": "kNXgXncBOgKHbob1dOxQ",
  "_version": 1,
  "_score": null,
  "_source": {
    "AggregateID": "7c2416a3-3985-4be5-928a-6091f491a41e",
    "Typology": "create",
    "Payload": {
      "AuthorID": 1,
      "Title": "ARTICLE TEST",
      "Content": "NEW CONTENT",
      "CreatedAt": "2021-02-01T18:35:04.1405348Z"
    },
    "CreatedAt": "2021-02-01T18:35:04.1405624Z",
    "Index": 1
  },
  "fields": {
    "CreatedAt": [
      "2021-02-01T18:35:04.140Z"
    ],
    "Payload.CreatedAt": [
      "2021-02-01T18:35:04.140Z"
    ]
  },
  "sort": [
    1612204504140
  ]
}

When i'm running my query nothing appears I have read the documentation several times and concluded that to find the exact AggregateID I should use a bool query:

{
    "query": {
        "bool": {
            "must": {
               "term": {
                    "AggregateID": "7c2416a3-3985-4be5-928a-6091f491a41e"
                }
            }
        }
    }
}

I also tried a term query but still the same I do not understand why only match queries are working.

{
    "query": {
        "term": {
            "AggregateID": {
                "value": "ef9c22c1-eb5c-4e08-ad5d-84f46060d563"
            }
        }
    }
}

Response is always the same:

{
    "took": 0,
    "timed_out": false,
    "_shards": {
        "total": 4,
        "successful": 4,
        "skipped": 0,
        "failed": 0
    },
    "hits": {
        "total": {
            "value": 0,
            "relation": "eq"
        },
        "max_score": null,
        "hits": []
    }
}

Some help will be appreciated a lot to point out what I am doing wrong.

Thanks a lot for your time and consideration guys.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.