我正在尝试按照 Elastic 5.x 的新标准对访问其内部关键字字段的文本属性进行术语筛选...
我有这样一个属性:
{
"foo": {
"type" "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
我正在运行以下代码以使用内部关键字字段进行过滤...
var searchResult = _elasticClient.Search<InvoiceResult>(x => x
.Index("my_index")
.Query(query => query
.Term(term => term
.Field(new Field("foo.keyword"))
.Value("TEST")
)
)
);
有什么方法可以使用模型类实现相同的结果吗?当我尝试下面的代码时,它从不使用关键字 inner field。
var searchResult = _elasticClient.Search<InvoiceResult>(x => x
.Index("my_index")
.Query(query => query
.Term(term => term
.Field(field => field.Foo)
.Value("TEST")
)
)
);
干杯!
最佳答案
鸟巢 has这种情况下非常方便的扩展方法。
var searchResult = _elasticClient.Search<InvoiceResult>(x => x
.Index("my_index")
.Query(query => query
.Term(term => term
.Field(field => field.Foo.Suffix("keyword"))
.Value("TEST")
)
)
);
希望对您有所帮助🤠。
关于.net - Elastic NEST 在具有内部关键字字段的文本字段上使用术语过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47201144/