I am very new to ES. While exploring NEST client for .Net I came across a situation which am not able to figure out how to achieve using NEST.Net.
Configuration : .Net 4.6.1 NEST 7.2.0
What I am trying is to set an alias on an existing index. I was able to achieve it using following.
await _client.Indices.PutAliasAsync(indexName, aliasName);
This creates an alias on index though alias is empty.
Now I wanted to achieve below structure.
"MyIndexName" : {
"aliases" : {
"MyAliasName" : {
"filter" : {
"term" : {
"MyFilterTerm" : "MyFilterTermValue"
}
}
},
}
I used below snippet
await _client.Indices.PutAliasAsync(indexName, aliasName,
a => a.Filter<MyTestClass>(
f => f.Term("MyFilterTerm", "MyFilterTermValue")));
public class MyTestClass {// not sure what this was supposed to be}
however this produces json as below.
"MyIndexName" : {
"aliases" : {
"MyAliasName" : {
"filter" : {
"term" : {
"MyFilterTerm" : {
"value" : "MyFilterTermValue"
}
}
}
},
}
How do I achieve the first JSON format?
The two JSON formats for the term
query in the filter
clause are the equivalent. NEST typically emits the longer form of queries, which for a term query is
"term" : {
"<field>" : {
"value" : "<value>"
}
}
as opposed to the short form
"term" : {
"<field>" : "<value>"
}