Elasticsearch Nest Boost query

自闭症网瘾萝莉.ら 提交于 2020-01-05 22:13:23

问题


Im trying to do a boosting query that reduces the score of documents where the field with name "type" and with the value "Press".

However NEST does not generate any values in the positive field in the generated json object:

  "query": {
    "boosting": {
      "positive": {},
      "negative": {
        "term": {
          "type": {
            "value": "Press"
          }
        }
      },
      "negative_boost": 0.2
    }
  }

Code Below:

var result = _elasticClient.Search<SearchablePage>(new SearchDescriptor<SearchablePage>()
                .Query(q => q
                    .Boosting(b => b
                        .NegativeBoost(0.2)
                        .Positive(p => p
                            .Filtered(fi => fi                        
                                .Filter(fq => fq
                                    .Term(t => t.Type, aggregation)
                                )
                                .Query(qq => qq
                                    .QueryString(qs => qs
                                        .Query(query)
                                        .OnFields(f => f.Name, f => f.Presentation, f => f.MainBody, f => f.SearchableBlocks.First().MainBody)
                                    )
                                )  
                            )
                        )
                        .Negative(n => n
                            .Term(f => f.OnField("type").Value("Press"))
                        )
                    )
                ));

来源:https://stackoverflow.com/questions/28302175/elasticsearch-nest-boost-query

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!