Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/269.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/8/meteor/3.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# 在嵌套7中添加附件管道_C#_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Nest - Fatal编程技术网 elasticsearch,nest,C#,elasticsearch,Nest" /> elasticsearch,nest,C#,elasticsearch,Nest" />

C# 在嵌套7中添加附件管道

C# 在嵌套7中添加附件管道,c#,elasticsearch,nest,C#,elasticsearch,Nest,我有这样的课: public class Document { public string Id { get; set; } public string Content { get; set; } public Attachment Attachment { get; set; } } 从文件(如pdf)中读取上下文,如下所示: 当我写一堆这样的文档时: var bulkResponse = client.Bulk(b => b .Pipeline("at

我有这样的课:

public class Document
{
    public string Id { get; set; }
    public string Content { get; set; }
    public Attachment Attachment { get; set; }
}
从文件(如pdf)中读取上下文,如下所示:

当我写一堆这样的文档时:

var bulkResponse = client.Bulk(b => b
    .Pipeline("attachments")
    .IndexMany(documents)
);
我得到:

"pipeline with id [attachments] does not exist"
类似的代码过去也能工作,但我现在切换到Nest 7

我使用此代码创建索引(用于工作):

client.index.Create(indexName,c=>c
.Settings(s=>s
.分析(a=>a
.分析仪(ad=>ad
.Custom(“windows\u路径\u层次结构\u分析器”,ca=>ca
.Tokenizer(“windows\u路径\u层次结构\u Tokenizer”)
)
)
.Tokenizers(t=>t
.PathHierarchy(“windows\u路径\u层次结构\u标记器”,ph=>ph
.分隔符(“\\”)
)
)
)
)
.Mappings(m=>m
.Map(mp=>mp
.AutoMap()
.AllField(all=>all
.已启用(错误)
)
.Properties(ps=>ps
.Object(a=>a
.Name(n=>n.Attachment)
.AutoMap()
)
)
)
)
);
我还遇到了类似的东西,可以用来定义附件管道

client.PutPipeline("attachments", p => p
                .Description("Document attachment pipeline")
                .Processors(pr => pr
                    .Attachment<Document>(a => a
                        .Field(f => f.Content)
                        .TargetField(f => f.Attachment)
                    )
                    .Remove<Document>(r => r
                        .Field(f => f.Content)
                    )
                )
            );
client.putpippeline(“附件”,p=>p
.说明(“文件附件管道”)
.处理器(pr=>pr
.附件(a=>a
.Field(f=>f.Content)
.TargetField(f=>f.Attachment)
)
.删除(r=>r
.Field(f=>f.Content)
)
)
);
附言:

这可能会起作用:

client.Ingest.PutPipeline("attachments", p => p
                .Description("Document attachment pipeline")
                .Processors(pr => pr
                    .Attachment<Document>(a => a
                        .Field(f => f.Content)
                        .TargetField(f => f.Attachment)
                    )
client.inset.putpippeline(“附件”,p=>p
.说明(“文件附件管道”)
.处理器(pr=>pr
.附件(a=>a
.Field(f=>f.Content)
.TargetField(f=>f.Attachment)
)
,从

使用系统;
使用Elasticsearch.Net;
利用鸟巢;
名称空间示例
{
私有静态void Main()
{
var defaultIndex=“附件”;
变量池=新的SingleNodeConnectionPool(新Uri(“http://localhost:9200"));
var设置=新连接设置(池)
.DefaultIndex(DefaultIndex)
.DisableDirectStreaming()
.PrettyJson()
.OnRequestCompleted(callDetails=>
{
if(callDetails.RequestBodyInBytes!=null)
{
控制台写入线(
$“{callDetails.HttpMethod}{callDetails.Uri}\n”+
$“{Encoding.UTF8.GetString(callDetails.RequestBodyInBytes)}”;
}
其他的
{
WriteLine($“{callDetails.HttpMethod}{callDetails.Uri}”);
}
Console.WriteLine();
if(callDetails.ResponseBodyInBytes!=null)
{
Console.WriteLine($“状态:{callDetails.HttpStatusCode}\n”+
$“{Encoding.UTF8.GetString(callDetails.ResponseBodyInBytes)}\n”+
$“{新字符串('-',30)}\n”);
}
其他的
{
Console.WriteLine($“状态:{callDetails.HttpStatusCode}\n”+
$“{新字符串('-',30)}\n”);
}
});
var客户端=新的ElasticClient(设置);
if(client.index.Exists(defaultIndex.Exists)
{
var deleteIndexResponse=client.index.Delete(defaultIndex);
}
var createIndexResponse=client.index.Create(defaultIndex,c=>c
.Settings(s=>s
.分析(a=>a
.分析仪(ad=>ad
.Custom(“windows\u路径\u层次结构\u分析器”,ca=>ca
.Tokenizer(“windows\u路径\u层次结构\u Tokenizer”)
)
)
.Tokenizers(t=>t
.PathHierarchy(“windows\u路径\u层次结构\u标记器”,ph=>ph
.分隔符(“\\”)
)
)
)
)
.Map(mp=>mp
.AutoMap()
.Properties(ps=>ps
.Text(s=>s
.Name(n=>n.Path)
.Analyzer(“windows\u路径\u层次结构\u分析器”)
)
.Object(a=>a
.Name(n=>n.Attachment)
.AutoMap()
)
)
)
);
var putPipelineResponse=client.inset.putpippeline(“附件”,p=>p
.说明(“文件附件管道”)
.处理器(pr=>pr
.附件(a=>a
.Field(f=>f.Content)
.TargetField(f=>f.Attachment)
)
.删除(r=>r
.Field(ff=>ff
.Field(f=>f.Content)
)
)
)
);
var base64File=Convert.ToBase64String(File.ReadAllBytes(@“C:\Users\russc\Dropbox\Other Linqpad querys\example_one.docx”);
var indexResponse=client.Index(新文档
{
Id=1,
Path=@“\\share\documents\examples\example\u one.docx”,
Content=base64File
},i=>i
.管道(“附件”)
.Refresh(Refresh.WaitFor)
);
var searchResponse=client.Search(s=>s
.Query(q=>q
.Match(m=>m
.Field(a=>a.Attachment.Content)
.Query(“嵌套”)
)
)
);
foreach(searchResponse.Hits中的var hit)
{
var attachment=hit.Source.attachment;
WriteLine($“doc id{hit.id}的附件详细信息”);
Console.WriteLine($“日期:{attachment.date}”);
WriteLine($“内容类型:{attachment.ContentType}”);
Console.WriteLine($”作者:{at
client.PutPipeline("attachments", p => p
                .Description("Document attachment pipeline")
                .Processors(pr => pr
                    .Attachment<Document>(a => a
                        .Field(f => f.Content)
                        .TargetField(f => f.Attachment)
                    )
                    .Remove<Document>(r => r
                        .Field(f => f.Content)
                    )
                )
            );
client.Ingest.PutPipeline("attachments", p => p
                .Description("Document attachment pipeline")
                .Processors(pr => pr
                    .Attachment<Document>(a => a
                        .Field(f => f.Content)
                        .TargetField(f => f.Attachment)
                    )