我正在尝试对文本属性执行术语过滤器,以遵循Elastic 5.x上的新标准来访问其内部关键字字段...
我有一个这样的财产:
{
"foo": {
"type" "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我正在运行以下代码以使用内部关键字字段进行过滤...
var searchResult = _elasticClient.Search<InvoiceResult>(x => x
.Index("my_index")
.Query(query => query
.Term(term => term
.Field(new Field("foo.keyword"))
.Value("TEST")
)
)
);
Run Code Online (Sandbox Code Playgroud)
使用模型类有什么方法可以达到相同的结果?当我尝试下面的代码时,它永远不会使用关键字inner field。
var searchResult = _elasticClient.Search<InvoiceResult>(x => x
.Index("my_index")
.Query(query => query
.Term(term => term
.Field(field => field.Foo)
.Value("TEST")
)
)
);
Run Code Online (Sandbox Code Playgroud)
干杯!
我正在尝试运行下面的代码,但是我在第一个SelectMany语句上遇到错误:" 'IEnumerable<TResult> System.Linq.Enumerable.SelectMany...'无法从用法中推断出方法的类型参数.请尝试明确指定类型参数".公司有一个列表Employments,我希望得到一个列表,所有employments公司都被调用"Company1",并且在我需要过滤后,员工当前正在工作(当EndDate为null时)并返回一个只有他们名字的列表.
我需要使用Linq查询来完成它.
var employees = FindAllCompanies()
.Where(x => x.Name == "Company1")
.SelectMany(x => x.Employments)
.Select(x => x.EmploymentEndDate == null)
.SelectMany(x.Name);
Run Code Online (Sandbox Code Playgroud)