タイトルが既に示しているので、私はMS Word文書を索引付けし、全文検索をしようとしています。Elasticsearch - MS Wordの添付ファイルを索引付けしようとしています。
私はいくつかの例を見ましたが、私が間違っていることを理解することはできません。
関連するコード:
[ElasticsearchType(Name = "AttachmentDocuments")]
public class Attachment
{
[String(Name = "_content")]
public string Content { get; set; }
[String(Name = "_content_type")]
public string ContentType { get; set; }
[String(Name = "_name")]
public string Name { get; set; }
public Attachment(Task<File> file)
{
Content = file.Result.FileContent;
ContentType = file.Result.FileType;
Name = file.Result.FileName;
}
}
上記の "コンテンツ" プロパティは、コンストラクタで "file.Result.FileContent" に設定されています。 "Content"プロパティは、base64文字列です。
public class Document
{
[Number(Name = "Id")]
public int Id { get; set; }
[Attachment]
public Attachment File { get; set; }
public String Title { get; set; }
}
以下は、elasticsearchデータベースにドキュメントをインデックスする方法です。
public void IndexDocument(Attachment attachmentDocument)
{
// Create the index if it does not already exist
var indexExists = _client.IndexExists(new IndexExistsRequest(ElasticsearchIndexName));
if (!indexExists.Exists)
{
var indexDescriptor =
new CreateIndexDescriptor(new IndexName {Name = ElasticsearchIndexName}).Mappings(
ms => ms.Map<Document>(m => m.AutoMap()));
_client.CreateIndex(indexDescriptor);
}
var doc = new Document()
{
Id = 1,
Title = "Test",
File = attachmentDocument
};
_client.Index(doc);
}
は、上記コードに基づいて、原稿が正しいインデックス(Elasticsearchホストからスクリーン - Searchly)にインデックスを取得:ファイルの内容である
"VCXCVXCVXCVXCVXVXCVXCV" と次のクエリで私はお返しにゼロヒットを取得:
QueryContainer queryContainer = null;
queryContainer |= new MatchQuery()
{
Field = "file",
Query = "VCXCVXCVXCVXCVXVXCVXCV"
};
var searchResult =
await _client.LowLevel.SearchAsync<string>(ApplicationsIndexName, "document", new SearchRequest()
{
From = 0,
Size = 10,
Query = queryContainer,
Aggregations = GetAggregations()
});
誰かが私が間違ってやっているものを私にヒントができれば、私はappericiateでしょう
かに見えるはずですか?
私Elasticsearchデータベースのマッピングのスクリーンショットを提供する:
です。コンテンツベース64ですか? –
コンテンツはbase64です。 –
なぜ画面に_contentがある場合、Field = "file"ですか? –