我使用Searchblox來索引和搜索我的文件,這些文件本身稱爲ES 2.x來完成這項工作。 Searchblox在創建索引時使用「mapping.json」文件來初始化映射。這是該文件的link。作爲「@Russ凸輪」建議here,我創建了自己的類的內容用下面的代碼(像他一樣的「問題」指數和「問題」類):無法從elasticsearch獲取NEST的任何文檔
public class Content
{
public string type { get; set; }
public Fields fields { get; set; }
}
public class Fields
{
public Content1 content { get; set; }
public Autocomplete autocomplete { get; set; }
}
public class Content1
{
public string type { get; set; }
public string store { get; set; }
public string index { get; set; }
public string analyzer { get; set; }
public string include_in_all { get; set; }
public string boost { get; set; }
} //got this with paste special->json class
從內容類的這些字段(類型,存儲等)來自上面附帶的mapping.json文件。現在,當我(就像你對我)執行以下代碼:
var searchResponse = highLevelclient.Search<Content>(s => s.Query(q => q
.Match(m => m.Field(f => f.fields.content)
.Query("service")
我得到的是對searchResponse變量的迴應是:
Valid NEST response built from a successful low level call on POST: /idx014/content/_search
Audit trail of this API call:
-HealthyResponse: Node: http://localhost:9200/ Took: 00:00:00.7180404
Request:
{"query":{"match":{"fields.content":{"query":"service"}}}}
Response:
{"took":1,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}
And no documents in searchResponse.Documents. Contradictorily, when I search for the "service" query on Searchblox or make an API call to localhost:9200 with the Sense extension of Google Chrome, I get 2 documents. (the documents that I was looking for)
總之,我要的是能:
- 得到的所有文件(無標準)
- 得到一個時間範圍內的所有文件和基於關鍵詞的..如「服務」
我在做什麼錯?如有需要,我可以提供更多信息。謝謝大家的詳細解答。
我調試了以下行: var searchResponse = highLevelclient.Search(s => query(q => q .Match(m => m.Field(f => f.fields.content).Query(「服務「) 並得到以下內容:[error](https://drive.google.com/open?id=0B1LnMWaj1afaQ0ltd0ExVGc3OTQ)。 爲什麼我得到_「方法只能在Type.IsGenericParameter爲true的類型上調用。」_錯誤?這個錯誤是否必須對我執行任何操作** get ** **文檔? –
cemowski23
您最好直接使用Searchblox api獲取json或xml格式的文檔。 – user7313404
此外,請檢查基本身份驗證憑據以訪問elasticsearch @ 9200,因爲Searchblox在訪問數據之前提供了一個安全層。 – user7313404