从NEST客户端获取原始查询 [英] Get raw query from NEST client

查看:71
本文介绍了从NEST客户端获取原始查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以从NEST客户端获取原始搜索查询?

Is it possible to get the raw search query from the NEST client?

var result = client.Search<SomeType>(s => s
                .AllIndices()
                .Type("SomeIndex")
                .Query(query => query
                    .Bool(boolQuery => BooleanQuery(searchRequest, mustMatchQueries)))
                );

我真的很想调试为什么我得到某些结果。

I'd really like to debug why I am getting certain results.

推荐答案

每个主要版本的执行方法似乎都不同,因此答案的数量令人困惑。 如果您希望它在NEST 6.x中工作,并且希望在反序列化请求实际发送之前看到它,,这很容易:

The methods to do this seem to change with each major version, hence the confusing number of answers. If you want this to work in NEST 6.x, AND you want to see the deserialized request BEFORE it's actually sent, it's fairly easy:

var json = elasticClient.RequestResponseSerializer.SerializeToString(request);

如果您在Visual Studio中进行调试,则在此行之后放置一个断点很方便,并且当您点击它时,将鼠标悬停在上面的 json 变量上,然后点击带放大镜的东西。您将获得一个漂亮的JSON格式化视图。

If you're debugging in Visual Studio, it's handy to put a breakpoint right after this line, and when you hit it, hover over the json variable above and hit the magnifying glass thingy. You'll get a nice formatted view of the JSON.

这篇关于从NEST客户端获取原始查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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