0
我使用fscrawler 2.3-SNAPSHOT爲位於文件夾「/ tmp/es」中的文檔編制索引。它映射他們爲:使用fscrawler進行ElasticSearch文件映射並使用CEST中的NEST搜索文檔#
{
"properties" : {
"attachment" : {
"type" : "binary",
"doc_values": false
},
"attributes" : {
"properties" : {
"group" : {
"type" : "keyword"
},
"owner" : {
"type" : "keyword"
}
}
},
"content" : {
"type" : "text"
},
"file" : {
"properties" : {
"content_type" : {
"type" : "keyword"
},
"filename" : {
"type" : "keyword"
},
"extension" : {
"type" : "keyword"
},
"filesize" : {
"type" : "long"
},
"indexed_chars" : {
"type" : "long"
},
"indexing_date" : {
"type" : "date",
"format" : "dateOptionalTime"
},
"last_modified" : {
"type" : "date",
"format" : "dateOptionalTime"
},
"checksum": {
"type": "keyword"
},
"url" : {
"type" : "keyword",
"index" : true
}
}
},
"object" : {
"type" : "object"
},
"meta" : {
"properties" : {
"author" : {
"type" : "text"
},
"date" : {
"type" : "date",
"format" : "dateOptionalTime"
},
"keywords" : {
"type" : "text"
},
"title" : {
"type" : "text"
},
"language" : {
"type" : "keyword"
}
}
},
"path" : {
"properties" : {
"encoded" : {
"type" : "keyword"
},
"real" : {
"type" : "keyword",
"fields": {
"tree": {
"type" : "text",
"analyzer": "fscrawler_path",
"fielddata": true
}
}
},
"root" : {
"type" : "keyword"
},
"virtual" : {
"type" : "keyword",
"fields": {
"tree": {
"type" : "text",
"analyzer": "fscrawler_path",
"fielddata": true
}
}
}
}
}
}
}
現在,我想在我的C#應用程序中使用NEST搜尋它們,我能夠hit.source.content
得到內容但不能被hit.source.filename
得到的文件名...
代碼:
var response = elasticClient.Search<documents>(s => s
.Index("tanks")
.Type("doc")
.Query(q => q.QueryString(qs => qs.Query(query))));
if (rtxSearchResult.Text != " ")
{
rtxSearchResult.Text = " ";
foreach (var hit in response.Hits)
{
rtxSearchResult.Text = rtxSearchResult.Text + ("Name: " + hit.Source.fileName.ToString()
+ Environment.NewLine
+ "Content: " + hit.Source.content.ToString()
+ Environment.NewLine
+ "URL: " + hit.Source.url.ToString()
+ Environment.NewLine
+ Environment.NewLine);
}
}
上述拋出NULLException但運行時,我的評論符合hit.Source.url
和hit.Source.filename
。
Kibana顯示文件名字段爲file.filename
,網址爲file.url
,內容爲content
。
作爲文件名,文件下嵌套,我無法找回......請幫助困在這裏夫婦現在天..
你的'文件'類型是什麼樣的?你能證明嗎? –