elasticsearch - C# - 用于原始 Json 查询的 ElasticSearch 低级搜索 API
问题描述
我将 ElasticSearch v6.4 与 Nest(v.6.4.2) 和 ElasticSearch.Net(v.6.4.2) 库一起使用。我正在尝试将 Search API 与我的 Raw Json 查询一起使用。
这是我的 JSON 查询模板:
var jsonQuery = @"{
"_source": {
"exclude": [],
"include": []
},
"query": {
"bool": {
"should": [
[
{
"multi_match": {
"query": "*",
"analyzer": "standard",
"type": "most_fields",
"fields": []
}
},
{
"multi_match": {
"query": "*",
"analyzer": "standard",
"type": "most_fields",
"fuzziness": 1,
"prefix_length": 3,
"fields": []
}
}
]
],
"filter": {
"bool": {
"must": [
{ "term": { "xx": "yy" } }
],
"must_not": [],
"should": [
{
"bool": {
"must": [
{ "term": { "xx": "yy" } },
{ "term": { "xx": "yy" } },
]
}
},
{
"bool": {
"must": [
{ "range": { "xx": { "gte": yy1, "lte": yy2 } } }
]
}
}
]
}
}
}
},
"from": 0,
"size": 500,
"min_score": 0.0,
"sort": [],
"aggs": {}
}"
首先,当我将此查询与 .Raw() 一起使用时,它会返回无效低级调用的错误。
其次,当我使用以下函数获取结果时:
var responseData = _connectionToEs.EsClient(_esInstanceUrl, _indexName).LowLevel.Search<myClass>(jsonQuery);
我收到以下错误:
The type 'myClass' cannot be used as type parameter 'TResponse' in the generic type or method IElasticLowLevelClient.Search<TResponse>(PostData, SearchRequestParameters). There is no implicit reference conversion from 'myClass' to 'Elasticsearch.Net.IElasticsearchResponse'
。
我被困在这个问题上很长一段时间了,还没有找到任何解决方案。如何使用原始 JSON 查询与 ElasticSearch.Net 函数一起使用它是嵌套函数还是低级函数?请帮忙。提前致谢!!!
解决方案
推荐阅读
- reactjs - 未找到模块:“draft-js-export-html”
- jberet - Jberet - 可重试的异常类工作?
- php - “不完整的文件”错误在php中下载带有标题的文件
- javascript - How to inciude a local html file in a webview in nativescript main-page.js?
- python - 按升序对月份名称字符串列表进行排序
- oracle - 是否可以删除具有 Referenced_Owner/Referenced_Name 的无效对象?(dba_dependencies)
- python - 多处理不返回所有值
- mysql - How to extract values from MySQL query in Ansible play
- python - 如何围绕其最小值对数组进行切片
- javascript - 根据 Vue 中的数据变化切换对象(使用 Vuex)