Base solution for your next web application
Open Closed

ElasticSearch Integration asp.net zero with angular #11966


User avatar
0
[email protected] created

Hello @ismcagdas, We are using Asp.net Zero V 13.0.0 with.NET Core and Angular. We want to integration Elasticsearch in our project.can you please send documentation. If any one already done, please send link.


5 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    This might give you an idea about how to integrate ElasticSearch, see https://aspnetzero.com/blog/how-to-save-audit-logs-to-elasticsearch

  • User Avatar
    0
    [email protected] created

    Hi,

    This might give you an idea about how to integrate ElasticSearch, see https://aspnetzero.com/blog/how-to-save-audit-logs-to-elasticsearch

    how to integration in Startup.CS file. & appsetting.json file. local elasticSearch setup run https://localhost:9200 working fine

    but i have create API then getting below error. so please what i should.

    appSetting.json

    "Elasticsearch": { "Url": "https://localhost:9200"
    },

    Startup var elasticSettings = _appConfiguration.GetSection("Elasticsearch").Get<ElasticsearchSettings>();

    // Configure Elasticsearch client var settings = new ConnectionSettings(new System.Uri(elasticSettings.Url)); var client = new ElasticClient(settings);

    // Register Elasticsearch client as a singleton service services.AddSingleton<IElasticClient>(client);

    i have below API public async Task<IEnumerable<Product>> SearchProductEntities(string indexName, string query) { try { var searchResponse = await _elasticClient.SearchAsync<Product>(s => s .Index(indexName) // Specify the index name .Query(q => q .Match(m => m .Field(f => f.productName) // Search in the ProductName field .Query(query) ) ) );

         if (searchResponse.IsValid)
         {
             return searchResponse.Documents;
         }
         else
         {
             // Handle search errors
             throw new Exception($"Error searching documents: {searchResponse.ServerError?.Error?.Reason}");
         }
     }
     catch (Exception ex)
     {
         throw;
     }
    

    } error:- The client is unable to verify that the server is Elasticsearch due to an unsuccessful product check call. Some functionality may not be compatible if the server is running an unsupported product. Call: Status code unknown from: GET /

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Could you share the full error message ? You can find in in your Logs.txt file under App_Data folder.

  • User Avatar
    0
    [email protected] created

    Hi,

    Could you share the full error message ? You can find in in your Logs.txt file under App_Data folder.

    Invalid NEST response built from a unsuccessful () low level call on POST: /_bulk

    Invalid Bulk items:

    Audit trail of this API call:

    • [1] ProductCheckOnStartup: Took: 00:00:00.0823455
    • [2] ProductCheckFailure: Node: https://localhost:9200/ Took: 00:00:00.0822299

    OriginalException: Elasticsearch.Net.ElasticsearchClientException: The client is unable to verify that the server is Elasticsearch due to an unsuccessful product check call. Some functionality may not be compatible if the server is running an unsupported product. Call: Status code unknown from: GET /

    ---> Elasticsearch.Net.PipelineException: The client is unable to verify that the server is Elasticsearch due to an unsuccessful product check call. Some functionality may not be compatible if the server is running an unsupported product. ---> System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception. ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid because of errors in the certificate chain: UntrustedRoot at System.Net.Security.SslStream.SendAuthResetSignal(ProtocolToken message, ExceptionDispatchInfo exception) at System.Net.Security.SslStream.CompleteHandshake(SslAuthenticationOptions sslAuthenticationOptions) at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](TIOAdapter adapter, Boolean receiveFirst, Byte[] reAuthenticationData, Boolean isApm) at System.Net.Security.SslStream.ProcessAuthenticationWithTelemetryAsync(Boolean isAsync, Boolean isApm, CancellationToken cancellationToken) at System.Net.Http.ConnectHelper.EstablishSslConnectionAsync(SslClientAuthenticationOptions sslOptions, HttpRequestMessage request, Boolean async, Stream stream, CancellationToken cancellationToken) --- End of inner exception stack trace --- at System.Net.Http.ConnectHelper.EstablishSslConnectionAsync(SslClientAuthenticationOptions sslOptions, HttpRequestMessage request, Boolean async, Stream stream, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.AddHttp11ConnectionAsync(HttpRequestMessage request) at System.Threading.Tasks.TaskCompletionSourceWithCancellation1.WaitWithCancellationAsync(CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.GetHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken) at Elasticsearch.Net.HttpConnection.RequestAsync[TResponse](RequestData requestData, CancellationToken cancellationToken) --- End of inner exception stack trace --- at Elasticsearch.Net.RequestPipeline.ThrowIfTransientProductCheckFailure() at Elasticsearch.Net.RequestPipeline.PingAsync(Node node, CancellationToken cancellationToken) at Elasticsearch.Net.Transport1.PingAsync(IRequestPipeline pipeline, Node node, CancellationToken cancellationToken) at Elasticsearch.Net.Transport`1.RequestAsync[TResponse](HttpMethod method, String path, CancellationToken cancellationToken, PostData data, IRequestParameters requestParameters) --- End of inner exception stack trace ---

    Request:

    <Request stream not captured or already read to completion by serializer. Set DisableDirectStreaming() on ConnectionSettings to force it to be set on the response.>

    Response:

    <Response stream not captured or already read to completion by serializer. Set DisableDirectStreaming() on ConnectionSettings to force it to be set on the response.>

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    As far as I can understand, this might be related to used certificate, please take a look at https://discuss.elastic.co/t/the-client-is-unable-to-verify-that-the-server-is-elasticsearch-due-to-an-unsuccessful-product-check-call/341510/2