Odd query help?

Is there a way to query for docs that contain one and only one keyword value?

For example, supposing these docs:

{"id": 1, "keywd": ["A"]}
{"id": 2, "keywd": ["B"]}
{"id": 3, "keywd": ["A", "B"]}

Is there a way to query for docs keywd = A and has no other values, so that only doc 1 would return and not doc 3?

One way would be by storing the length of the array in addition to the values.
If you search for A, then the size of the array must be 1.

Using a bool query with those 2 clauses would work I think.

That was exactly the solution, thank you!