1

AWS と CloudSearch は初めてです。docx ドキュメント (すでに cs-import-document を使用して JSON 形式に変換しています) を検索ドメインにアップロードするための非常に単純なアプリを作成しました。

コードは次のように非常に簡単です。

using (var searchdomainclient = new AmazonCloudSearchDomainClient("http://search-xxxxx-xysjxyuxjxjxyxj.ap-southeast-2.cloudsearch.amazonaws.com"))
{

    // Test to upload doc                            

    var uploaddocrequest = new UploadDocumentsRequest()
    {
        FilePath = @"c:\temp\testsearch.sdf",  //docx to JSON already
        ContentType =  ContentType.ApplicationJson

    };
    var uploadresult = searchdomainclient.UploadDocuments(uploaddocrequest);

   }

ただし、例外は「ルート要素がありません」です。

アップロードしたいsdfファイルのJSONは次のとおりです。

[{
    "type": "add",
    "id": "c:_temp_testsearch.docx",
    "fields": {
        "template": "Normal.dotm",
        "application_name": "Microsoft Office Word",
        "paragraph_count": "1",
        "resourcename": "testsearch.docx",
        "date": "2014-07-28T23:52:00Z",
        "xmptpg_npages": "1",
        "page_count": "1",
        "publisher": "",
        "creator": "John Smith",
        "creation_date": "2014-07-28T23:52:00Z",
        "content": "Test5",
        "author": "John Smith",
        "last_modified": "2014-07-29T04:22:00Z",
        "revision_number": "3",
        "line_count": "1",
        "application_version": "15.0000",
        "last_author": "John Smith",
        "character_count": "5",
        "character_count_with_spaces": "5",
        "content_type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
    }
}]

では、私のアプローチの何が問題なのですか?

ありがとうございます!

PS docx doc をその検索ドメインに手動でアップロードし、C# コードを使用して検索を適用できます。




============= 2014-08-04 更新 ===================

これに関係があるかどうかはわかりません。スタック トレースで、JSON ではなく XML ファイルとして解析しようとしていることがわかりました。しかし、私のコードからは既に ContentType = JASON を設定していますが、効果がないようです。

at System.Xml.XmlTextReaderImpl.ThrowWithoutLineInfo(String res)
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at Amazon.Runtime.Internal.Transform.XmlUnmarshallerContext.Read()
at Amazon.Runtime.Internal.Transform.ErrorResponseUnmarshaller.Unmarshall(XmlUnmarshallerContext context)
at Amazon.Runtime.Internal.Transform.JsonErrorResponseUnmarshaller.Unmarshall(JsonUnmarshallerContext context)
at Amazon.CloudSearchDomain.Model.Internal.MarshallTransformations.UploadDocumentsResponseUnmarshaller.UnmarshallException(JsonUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
at Amazon.Runtime.Internal.Transform.JsonResponseUnmarshaller.UnmarshallException(UnmarshallerContext input, Exception innerException, HttpStatusCode statusCode)
at Amazon.Runtime.AmazonWebServiceClient.HandleHttpWebErrorResponse(AsyncResult asyncResult, WebException we)
at Amazon.Runtime.AmazonWebServiceClient.getResponseCallback(IAsyncResult result)
at Amazon.Runtime.AmazonWebServiceClient.endOperation[T](IAsyncResult result)
at Amazon.CloudSearchDomain.AmazonCloudSearchDomainClient.EndUploadDocuments(IAsyncResult asyncResult)
at Amazon.CloudSearchDomain.AmazonCloudSearchDomainClient.UploadDocuments(UploadDocumentsRequest request)


at Amazon.CloudSearchDomain.Model.Internal.MarshallTransformations.UploadDocumentsResponseUnmarshaller.UnmarshallException(JsonUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
4

2 に答える 2

2

ドキュメント ID に無効な文字 (ピリオドとコロン) が含まれています。https://aws.amazon.com/articles/8871401284621700から:

ID は、ドメインにアップロードするすべてのドキュメントで一意である必要があり、次の文字を含めることができます: az (小文字)、0-9、およびアンダースコア文字 (_)。ドキュメント ID は、文字または数字で始まる必要があり、最大 64 文字です。

投稿先のエンドポイントも不明ですが、そこにも問題がある可能性があります。

于 2014-08-04T04:05:28.763 に答える
0

SDK バージョン 2.2.2.0 でもまったく同じ例外がありました。SDK をバージョン 2.2.2.1 に更新すると、例外がなくなりました。

于 2014-08-06T14:29:40.147 に答える