I'm a C# / Web / Javascript developer. I originally wrote an ElasticSearch app years ago on v2. I'm now building a new app with v6.2 but trying to use some of the same NEST code from before.
Some of this code is for building combined term-based queries based on selections made client-side.
What's happening is this:
I'm building my query in NEST - it's parameter driven, so field/value are all parameters.
compoundQuery |= new BoolQuery
{
Should = new QueryContainer[] {
new TermQuery()
{
Field = tv.FieldName,
Value = tv.Value,
},
}
....which according to the docs should result in this JSON....
{
"term": {
"fieldname": {
"value": "myvaluegoeshere"
}
}
}
....but is ACTUALLY resulting in this JSON......
"term": {
"fieldname": {
"value": [
"myvaluegoeshere"
]
}
}
NOTE: The extra array modifier around the [value].
The query still seems to be valid, but it doesn't find anything, whereas the "correct" query - without the [] - works and does find matching documents.
How do I get the query I want using NEST?