C# Elasticsearch嵌套Demax Morelike此查询形成空json字符串
我想使用NEST库在Elasticsearch上使用更相似的查询,并为每个匹配提供不同的提升值C# Elasticsearch嵌套Demax Morelike此查询形成空json字符串,c#,json,
elasticsearch,nest,morelikethis,C#,Json,
elasticsearch,Nest,Morelikethis,我想使用NEST库在Elasticsearch上使用更相似的查询,并为每个匹配提供不同的提升值 var moreLikeThis = _elastic.Search<Report>(s => s .From(0) .Size(10) .Query(q => q .Filtered(f => f .Query(fq => fq .Dismax(dmx => dm
var moreLikeThis = _elastic.Search<Report>(s => s
.From(0)
.Size(10)
.Query(q => q
.Filtered(f => f
.Query(fq => fq
.Dismax(dmx => dmx
.TieBreaker(0.7)
.Queries(qr => qr
.MoreLikeThis(mlt => mlt
.OnFields(of => of.Title.Suffix("stemmed"))
.MinTermFrequency(1)
.MaxQueryTerms(12)
.Boost(20)
.Documents(docs => docs
.Document() // This is the part where I'm stuck
)
), qr => qr
.MoreLikeThis(mlt => mlt
.OnFields(of => of.Title.Suffix("synonym"))
.MinTermFrequency(1)
.MaxQueryTerms(12)
.Boost(10)
)
)
)
)
)
)
);
这就是我作为JSON使用的查询,它工作得很好
{
"from": 0,
"size": 10,
"fields": ["Title"],
"query": {
"filtered": {
"query": {
"dis_max": {
"tie_breaker": 0.7,
"queries": [
{
"more_like_this": {
"fields": ["Title.stemmed"],
"docs": [
{
"_index": "test",
"_type": "reports",
"_id": "68753"
}
],
"min_term_freq": 1,
"max_query_terms": 12
}
}, {
"more_like_this": {
"fields": ["Title.synonym"],
"docs": [
{
"_index": "test",
"_type": "reports",
"_id": "68753"
}
],
"min_term_freq": 1,
"max_query_terms": 12
}
}
]
}
}
}
}
}
中的文档没有解释或给出如何完成此操作的基本概念
谢谢。如评论中所述,这是一个bug,将与1.5.2 NEST版本一起修复 看起来像只虫子。此问题的PR在这里@Rob Well谢谢您,先生,希望dev能解决它。:)@罗伯:也许你可以把你的评论作为答案提交给我,这样我就可以投票并将其标记为接受?没关系。谢谢:)
{
"from": 0,
"size": 10,
"fields": ["Title"],
"query": {
"filtered": {
"query": {
"dis_max": {
"tie_breaker": 0.7,
"queries": [
{
"more_like_this": {
"fields": ["Title.stemmed"],
"docs": [
{
"_index": "test",
"_type": "reports",
"_id": "68753"
}
],
"min_term_freq": 1,
"max_query_terms": 12
}
}, {
"more_like_this": {
"fields": ["Title.synonym"],
"docs": [
{
"_index": "test",
"_type": "reports",
"_id": "68753"
}
],
"min_term_freq": 1,
"max_query_terms": 12
}
}
]
}
}
}
}
}