弹性搜索和NEST:使用查找进行过滤 [英] Elasticsearch and NEST: Filtering with Lookups

查看:102
本文介绍了弹性搜索和NEST:使用查找进行过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是Elasticsearch 1.7.x(和NEST 1.7.2),并尝试利用如下所示的查找过滤:术语过滤器查找。我可以手工制作JSON,以获得我想要的请求,并使用Sense执行它。工作伟大,真棒功能!不过,在NEST图书馆,我没有看到创建这样一个条款条款的方法。例如,从上面提到的链接,我可以执行以下操作:

I'm using Elasticsearch 1.7.x (and NEST 1.7.2) and trying to take advantage of filtering with lookups as documented here: Terms Filter Lookup. I'm able to craft the JSON by hand for the request I desire and execute it using Sense. Works great, awesome feature! However, in the NEST library, I don't see a way to create such a terms clause. For example, from the link referenced above, I can do something like:

"terms" : {
   "proteins" : {
      "index" : "microarrays",
      "type" : "experiment",
      "id" : "experiment1234",
      "path" : "upregulated_proteins"
   },
   "_cache_key" : "experiment_1234"
}

有没有办法使用NEST构建这个查询?如果没有,有没有办法在建立NEST查询时注入一些JSON?我不知道NEST 2.x +是否支持,但升级到ES 2.x是我们的长期计划,我想利用ES 1.7中已经提供的功能。

Is there a way to build this query using NEST? If not, is there a way I can inject some JSON into a NEST query as I'm building it? I don't know if NEST 2.x+ supports this but upgrading to ES 2.x is a longer term plan for us and I'd like to leverage functionality that is already available in ES 1.7.

推荐答案

真棒,我已经收到了 Greg Marzouka 弹性!他说:

Awesome, I've already received an answer from Greg Marzouka of Elastic! He says:


它被映射为1.x中的TermsLookup()或TermsLookupFilter。查看单元测试的一些例子。



client.Search<Paper>(s => s
   .Query(q => q
      .Filtered(fq => qf
         .Filter(f => f
            .CacheKey("experiment_1234")
            .TermsLookup(t => t
               .Lookup<Protein>(p => p.UnregulatedProteins, "experiment1234", "microarrays", "experiment") 
            )
         )
      )
   ));




在2.x中,它与ES查询DSL更一致。

In 2.x it's a little more aligned with the ES query DSL.

这篇关于弹性搜索和NEST:使用查找进行过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆