2
我試圖使用NEST SearchRequest對象在我的ElasticSearch索引中查詢類型的動態列表。我如何在我的ElasticSearch查詢中看到NEST.SearchRequest.Type屬性的影響
public object Search(object runTimeData)
{
var request = new SearchRequest()
{
From = 0,
Size = 10
};
request = SetRouting(request, runTimeData);
request = SetIndices(request, runTimeData);
request = SetTypes(request, runTimeData);
request = SetQuery(request, runTimeData);
...
var results = _searchClient.Search<BaseOfAllTypes>(request);
return results;
}
...
private SearchRequest SetTypes(SearchRequest request, object runTimeData)
{
request.Types = GetTypesForRuntime(runTimeData);
}
如果我打電話System.Text.Encoding.UTF8.GetString(_searchClient.Serializer.Serialize(request))
通過我在哪裏我執行搜索行調試器,我看不出在JSON相關類型的東西:
{
"from": 0,
"size": 10,
"query": {
"bool": {
"must": [
{
"simple_query_string": {
"query": "my query data here",
"default_operator": "and"
}
}
]
}
}
}
查詢結果回來就好像然而,類型正在被適當地過濾。直接通過elasticsearch-head運行生成的JSON會返回所有類型的結果,所以看起來好像我在請求的序列化中沒有看到我真正應該看到的內容。