Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用fscrawler的ElasticSearch文件映射和在C中通过嵌套搜索文档#_C#_Wpf_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Nest_Fscrawler - Fatal编程技术网 elasticsearch,nest,fscrawler,C#,Wpf,elasticsearch,Nest,Fscrawler" /> elasticsearch,nest,fscrawler,C#,Wpf,elasticsearch,Nest,Fscrawler" />

C# 使用fscrawler的ElasticSearch文件映射和在C中通过嵌套搜索文档#

C# 使用fscrawler的ElasticSearch文件映射和在C中通过嵌套搜索文档#,c#,wpf,elasticsearch,nest,fscrawler,C#,Wpf,elasticsearch,Nest,Fscrawler,我使用fscrawler 2.3-SNAPSHOT为文件夹“/tmp/es”中的文档编制了索引。它将它们映射为: { "properties" : { "attachment" : { "type" : "binary", "doc_values": false }, "attributes" : { "properties" : { "group" : { "type" : "keyword"

我使用fscrawler 2.3-SNAPSHOT为文件夹“/tmp/es”中的文档编制了索引。它将它们映射为:

{
  "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);
                }
            }
var response=elasticClient.Search(s=>s
.索引(“储罐”)
.Type(“doc”)
.Query(q=>q.QueryString(qs=>qs.Query(Query)));
如果(rtxSearchResult.Text!=“”)
{
rtxSearchResult.Text=“”;
foreach(响应中的var hit.Hits)
{
rtxSearchResult.Text=rtxSearchResult.Text+(“名称:”+hit.Source.fileName.ToString()
+环境新线
+内容:“+hit.Source.Content.ToString()
+环境新线
+URL:+hit.Source.URL.ToString()
+环境新线
+环境(新线),;
}
}
上面的抛出NULLException,但在我使用
hit.Source.url
hit.Source.filename
注释行时运行

Kibana将文件名字段显示为
file.filename
,url显示为
file.url
,内容显示为
content

由于文件名嵌套在文件下,我无法检索它…请帮助我在这里停留几天。

发现错误:

我的文件课是:

Class documents
{
      Public string filename { get; set; }

      Public string content { get; set; }

      Public string url { get; set; }
}
由于文件名和url分别为
file.filename
file.url
,我们需要另一个带有文件名和url的类文件

Class documents
{
      Public File file { get; set; }

      Public string content { get; set; }

}

Class File
{
          Public string filename { get; set; }

          Public string url { get; set; }
}

因此,我可以通过
hit.Source.file.filename
hit.Source.file.url

访问它们,您的类型
文档是什么样子的?你能给我看看吗?