【发布时间】:2019-05-21 10:46:59
【问题描述】:
所有, 我正在构建一个 NEST 6.x 查询,该查询采用 serach 术语并查看不同索引中的不同字段。 这是我目前得到的结果,但没有返回任何我期望的结果。
请看下面的详细信息
使用的指数
- 开发样本搜索
- 用户代理搜索
搜索的工作方式如下。
查询字段中的值 (27921093) 是针对 字段agentNumber、customerName、fileNumber、documentid(这些都是 分析的文件)。
搜索应将文档限制为用户的 agentNumbers sampleuser@gmail.com 有权访问( user-agents-search)添加在下面。
agentNumber、customerName、fileNumber、documentid 和状态是 索引 dev-sample-search 的一部分。
status 字段被定义为keyword。
-
user-agents-search索引中的字段都是keywords
用户代理搜索索引数据示例:
{ "id": "sampleuser@gmail.com"", "user": "sampleuser@gmail.com"", "agentNumber": [ "123.456.789", "1011.12.13.14" ] }
dev-sample-search 索引数据示例:
{
"agentNumber": "123.456.789",
"customerName": "Bank of america",
"fileNumber":"test_file_1123",
"documentid":"1234456789"
}
GET dev-sample-search/_search
{
"from": 0,
"size": 10,
"query": {
"bool": {
"must": [
{
"multi_match": {
"type": "best_fields",
"query": "27921093",
"operator": "and",
"fields": [
"agentNumber",
"customerName",
"fileNumber",
"documentid^10"
]
}
}
],
"filter": [
{
"bool": {
"must": [
{
"terms": {
"agentNumber": {
"index": "user-agents-search",
"type": "_doc",
"user": "sampleuser@gmail.com",
"path": "agentNumber"
}
}
},
{
"bool": {
"must_not": [
{
"terms": {
"status": {
"value": "pending"
}
}
},
{
"term": {
"status": {
"value": "cancelled"
}
}
},
{
"term": {
"status": {
"value": "app cancelled"
}
}
}
],
"should": [
{
"term": {
"status": {
"value": "active"
}
}
},
{
"term": {
"status": {
"value": "terminated"
}
}
}
]
}
}
]
}
}
]
}
}
}
【问题讨论】:
标签: elasticsearch nest