查询NEST 5.0.0-rc1时发送空请求

时间:2016-11-08 12:09:11

标签: nest

问题基本上是无论我构建哪个查询,它都不会发送到elasticsearch。 比如这个:

_elasticClient.SearchAsync<CostSearch>(d =>
                d.Query(q =>
                    q.Match(f => f.Field(c => c.AgencyTrackingNo == costQuery.Query))
                )
            ); 

发送的请求是一个空对象,这意味着我从该索引获取所有值并输入。 您可以在以下日志中检查:

[11:47:36 INF] POST http://localhost:9200/costs/costsearch/_search 请求: {} 状态:200

{"took":1,"timed_out":false,"_shards":{"total":1,"successful":1,"failed":0},"hit
s":{"total":1,"max_score":1.0,"hits":[{"_index":"costs","_type":"costsearch","_i
d":"1","_score":1.0,"_source":{
    "id": "-0897-98df7-df8-96",
    "title": "Test cost",
    "budget": 12323.34,
    "contentType": "Photo",
    "agencyTrackingNo": "GL036001V",
    "agencyProducer": "Grey, New York",
    "costOwner": "John Doe guid",
    "stage": "Draft",
    "approvalStatus": "ToBeApproved",
    "ioNumber": "IO123854B",
    "initiative": "Gillete 2016",
    "budgetRegion": "Japan",
    "country": "countryid",
    "city": "cityid",
    "userGroups": ["1987", "1986"]
}
}]}

1 个答案:

答案 0 :(得分:1)

我的不好,结果我误用了Field选择器。

_elasticClient.SearchAsync<CostSearch>(d =>
                d.Query(q =>
                    q.Match(f => f.Field(c => c.AgencyTrackingNo).Query(costQuery.Query))
                )
            );