ElasticSearch doesn't work with synonym server

Hi,

I’ve been following the tutorial and I’ve ran into issues when trying to set up ElasticSearch and Synonym Server. When configuring synonyms like in the tutorial:

"Elasticsearch": {
      "ConnectionString": "http://localtest.me:9200",
      "Username": null,
      "Password": null,
      "Prefix": "LitiumEducation",
      "Synonym": {
        "Server": "http://localtest.me:9210"
      }
    }

I’m getting a 400 Bad Request error when trying to search for anything in accelerator.

Elasticsearch.Net.ElasticsearchClientException: Request failed to execute. Call: Status code 400 from: POST /litiumeducation.aq.productdocument.en-us/_search?typed_keys=true. ServerError: Type: search_phase_execution_exception Reason: "all shards failed"
   at Litium.Search.SearchExtensions.EnsureSuccessStatusCode[T](T response)
   at Litium.Application.Search.SearchClientServiceImpl.SearchAsync[T](CultureInfo culture, Func`2 descriptor)
   at Litium.Accelerator.Search.Searching.ProductSearchServiceDecorator.SearchAsync(SearchQuery searchQuery, IDictionary`2 tags, Boolean addPriceFilterTags, Boolean addNewsFilterTags, Boolean addCategoryFilterTags) in C:\Users\MPAW\Documents\litium\Tutorial\Src\Litium.Accelerator.Elasticsearch\Searching\ProductSearchServiceDecorator.cs:line 76
   at Litium.Accelerator.Searchers.ProductSearcher.QueryCompactAsync(String query, Boolean includeScore) in C:\Users\MPAW\Documents\litium\Tutorial\Src\Litium.Accelerator\Searchers\ProductSearcher.cs:line 31
   at Litium.Accelerator.Builders.Search.QuickSearchResultViewModelBuilder.BuildAsync(String query) in C:\Users\MPAW\Documents\litium\Tutorial\Src\Litium.Accelerator\Builders\Search\QuickSearchResultViewModelBuilder.cs:line 34
   at Litium.Accelerator.Mvc.Controllers.Api.QuickSearchController.Post(String query) in C:\Users\MPAW\Documents\litium\Tutorial\Src\Litium.Accelerator.Mvc\Controllers\Api\QuickSearchController.cs:line 27
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Microsoft.AspNetCore.Builder.AppBuilderExtensions.<>c.<<UseLitiumCart>b__3_0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Builder.AppBuilderExtensions.<>c.<<UseLitiumCart>b__3_0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Builder.AppBuilderExtensions.<>c__DisplayClass2_0.<<UseLitiumRouting>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Litium.Web.Runtime.Throttling.RateLimiterMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events, IBackChannelLogoutService backChannelLogoutService)
   at IdentityServer4.Hosting.MutualTlsEndpointMiddleware.Invoke(HttpContext context, IAuthenticationSchemeProvider schemes)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at IdentityServer4.Hosting.BaseUrlMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

And in the backoffice I can see that the indexes are marked yellow for search. However when I leave synonyms not configured the search is working fine:

"Elasticsearch": {
      "ConnectionString": "http://localtest.me:9200",
      "Username": null,
      "Password": null,
      "Prefix": "LitiumEducation",
      "Synonym": {
        "Server": null
      }
    }

I found a similar issue in the forum but the links in the accepted answer are dead. Any help would be appreciated.

Also when Synonym Server is configured I get the following error when trying to rebuild indices offline:

Elasticsearch.Net.ElasticsearchClientException: Request failed to execute. Call: Status code 400 from: PUT /litiumeducation.v2.categorydocument.en-us. ServerError: Type: illegal_argument_exception Reason: "Unknown filter type [dynamic_synonym] for [synonymFilter]" at Litium.Search.SearchExtensions.EnsureSuccessStatusCode[T](T response) at Litium.Application.Search.Schemas.IndexSchemaConfigurationService.CreateIndexIfMissing(String indexName, IIndexState indexState) at Litium.Application.Search.Schemas.IndexSchemaConfigurationService.EnsureSchema(IIndexMappingConfiguration configuration, String indexName, String culture) at Litium.Application.Search.Schemas.IndexSchemaMaintenanceService.EnsureIndexConfiguraiton(IIndexMappingConfiguration indexConfiguration, String culture) at Litium.Application.Search.Schemas.IndexSchemaMaintenanceService.SchemaChanged(ChangeSchemaNotification obj) at Litium.Application.Search.Schemas.IndexSchemaVersionServiceImpl.Notify(ChangeSchemaNotification event) at Litium.Application.Search.Schemas.IndexSchemaVersionServiceImpl.CreatePendingVersionAsync(String documentName) at Litium.Application.Search.IndexConfigurationServiceImpl.QueueIndexRebuildOfflineAsync(IIndexMappingConfiguration config) at Litium.Application.Search.IndexConfigurationServiceImpl.InvokeActionAsync(String index, String action, Object args) at Litium.Web.Administration.WebApi.Settings.Controllers.SearchIndexController.<>c__DisplayClass4_0.<b__0>d.MoveNext() --- End of stack trace from previous location --- at Litium.Web.Administration.WebApi.Settings.Controllers.SearchIndexController.RebuildIndex(String indexName, String actionName) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ExceptionContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger) at Microsoft.AspNetCore.Builder.AppBuilderExtensions.<>c.<b__3_0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Builder.AppBuilderExtensions.<>c.<b__3_0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Builder.AppBuilderExtensions.<>c__DisplayClass2_0.<b__0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Authorization.Policy.AuthorizationMiddlewareResultHandler.HandleAsync(RequestDelegate next, HttpContext context, AuthorizationPolicy policy, PolicyAuthorizationResult authorizeResult) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events, IBackChannelLogoutService backChannelLogoutService) at IdentityServer4.Hosting.MutualTlsEndpointMiddleware.Invoke(HttpContext context, IAuthenticationSchemeProvider schemes) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at IdentityServer4.Hosting.BaseUrlMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context) 

It could be issues with docker. Does docker-desktop show any errors for the elastic container?
What version of DockerDesktop are you running and what does your docker-compose file look like?

According to the tutorial, you should use "ConnectionString": "http://localhost:9200" for the database connectionstring and "Server": "http://host.docker.internal:9210" for synonym server.

I’ve been trying to follow some other threads and the forum and trying out different addresses, but none of them work, including the one from the tutorial.

"Elasticsearch": {
      "ConnectionString": "http://localhost:9200",
      "Username": null,
      "Password": null,
      "Prefix": "LitiumEducation",
      "Synonym": {
        "Server": "http://host.docker.internal:9210"
      }
    },

Still getting exactly the same issue.
In ElasticSearch container I’m getting these errors:

2023-05-30 10:00:42 {"type": "server", "timestamp": "2023-05-30T08:00:42,876Z", "level": "WARN", "component": "r.suppressed", "cluster.name": "docker-cluster", "node.name": "d194c7a34469", "message": "path: /.kibana_task_manager/_search, params: {ignore_unavailable=true, index=.kibana_task_manager}", "cluster.uuid": "7LVyl6TCTEyzval2BPSKqw", "node.id": "zBiq_ksQQo6_N3jT2Xj9Tg" , 
2023-05-30 10:00:42 "stacktrace": ["org.elasticsearch.action.search.SearchPhaseExecutionException: all shards failed",
2023-05-30 10:00:42 "at org.elasticsearch.action.search.AbstractSearchAsyncAction.onPhaseFailure(AbstractSearchAsyncAction.java:545) [elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:00:42 "at org.elasticsearch.action.search.AbstractSearchAsyncAction.executeNextPhase(AbstractSearchAsyncAction.java:306) [elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:00:42 "at org.elasticsearch.action.search.AbstractSearchAsyncAction.onPhaseDone(AbstractSearchAsyncAction.java:574) [elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:00:42 "at org.elasticsearch.action.search.AbstractSearchAsyncAction.onShardFailure(AbstractSearchAsyncAction.java:386) [elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:00:42 "at org.elasticsearch.action.search.AbstractSearchAsyncAction.access$200(AbstractSearchAsyncAction.java:66) [elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:00:42 "at org.elasticsearch.action.search.AbstractSearchAsyncAction$1.onFailure(AbstractSearchAsyncAction.java:242) [elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:00:42 "at org.elasticsearch.action.search.SearchExecutionStatsCollector.onFailure(SearchExecutionStatsCollector.java:73) [elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:00:42 "at org.elasticsearch.action.ActionListenerResponseHandler.handleException(ActionListenerResponseHandler.java:59) [elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:00:42 "at org.elasticsearch.action.search.SearchTransportService$ConnectionCountingHandler.handleException(SearchTransportService.java:423) [elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:00:42 "at org.elasticsearch.transport.TransportService$ContextRestoreResponseHandler.handleException(TransportService.java:1130) [elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:00:42 "at org.elasticsearch.transport.TransportService$DirectResponseChannel.processException(TransportService.java:1239) [elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:00:42 "at org.elasticsearch.transport.TransportService$DirectResponseChannel.sendResponse(TransportService.java:1213) [elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:00:42 "at org.elasticsearch.transport.TaskTransportChannel.sendResponse(TaskTransportChannel.java:60) [elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:00:42 "at org.elasticsearch.action.support.ChannelActionListener.onFailure(ChannelActionListener.java:56) [elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:00:42 "at org.elasticsearch.action.ActionListener$1.onFailure(ActionListener.java:71) [elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:00:42 "at org.elasticsearch.action.ActionListener$1.onResponse(ActionListener.java:65) [elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:00:42 "at org.elasticsearch.action.ActionRunnable.lambda$supply$0(ActionRunnable.java:58) [elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:00:42 "at org.elasticsearch.action.ActionRunnable$2.doRun(ActionRunnable.java:73) [elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:00:42 "at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:00:42 "at org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:44) [elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:00:42 "at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:692) [elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:00:42 "at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:00:42 "at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]",
2023-05-30 10:00:42 "at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]",
2023-05-30 10:00:42 "at java.lang.Thread.run(Thread.java:830) [?:?]"] }
2023-05-30 10:14:18 {"type": "server", "timestamp": "2023-05-30T08:14:18,137Z", "level": "DEBUG", "component": "o.e.a.s.TransportSearchAction", "cluster.name": "docker-cluster", "node.name": "d194c7a34469", "message": "[litiumeducation.v2.productdocument.en-us][0], node[zBiq_ksQQo6_N3jT2Xj9Tg], [P], s[STARTED], a[id=6DGpmLX4RXScY05sM9bNag]: Failed to execute [SearchRequest{searchType=QUERY_THEN_FETCH, indices=[litiumeducation.aq.productdocument.en-us], indicesOptions=IndicesOptions[ignore_unavailable=false, allow_no_indices=true, expand_wildcards_open=true, expand_wildcards_closed=false, allow_aliases_to_multiple_indices=true, forbid_closed_indices=true, ignore_aliases=false, ignore_throttled=true], types=[], routing='null', preference='null', requestCache=null, scroll=null, maxConcurrentShardRequests=0, batchedReduceSize=512, preFilterShardSize=128, allowPartialSearchResults=true, localClusterAlias=null, getOrCreateAbsoluteStartMillis=-1, ccsMinimizeRoundtrips=true, source={\"from\":0,\"size\":20,\"query\":{\"bool\":{\"must\":[{\"bool\":{\"filter\":[{\"term\":{\"channelSystemId\":{\"value\":\"dc6fc8d1-d778-48cf-9b2c-bca765d03ac7\",\"boost\":1.0}}},{\"term\":{\"assortments\":{\"value\":\"09a2522a-aaba-415e-a64e-ba65b373119f\",\"boost\":1.0}}},{\"term\":{\"organizations\":{\"value\":\"00000000-0000-0000-0000-000000000000\",\"boost\":1.0}}}],\"adjust_pure_negative\":true,\"boost\":1.0}},{\"bool\":{\"should\":[{\"match\":{\"name\":{\"query\":\"lkj\",\"operator\":\"OR\",\"analyzer\":\"synonymAnalyzer\",\"fuzziness\":\"AUTO\",\"prefix_length\":0,\"max_expansions\":50,\"fuzzy_transpositions\":true,\"lenient\":false,\"zero_terms_query\":\"NONE\",\"auto_generate_synonyms_phrase_query\":true,\"boost\":10.0}}},{\"match\":{\"name.ngram\":{\"query\":\"lkj\",\"operator\":\"OR\",\"analyzer\":\"synonymAnalyzer\",\"prefix_length\":0,\"max_expansions\":50,\"fuzzy_transpositions\":true,\"lenient\":false,\"zero_terms_query\":\"NONE\",\"auto_generate_synonyms_phrase_query\":true,\"boost\":20.0}}},{\"match\":{\"articleNumber\":{\"query\":\"lkj\",\"operator\":\"OR\",\"prefix_length\":0,\"max_expansions\":50,\"fuzzy_transpositions\":true,\"lenient\":false,\"zero_terms_query\":\"NONE\",\"auto_generate_synonyms_phrase_query\":true,\"boost\":2.0}}},{\"match\":{\"content\":{\"query\":\"lkj\",\"operator\":\"OR\",\"analyzer\":\"synonymAnalyzer\",\"fuzziness\":\"AUTO\",\"prefix_length\":0,\"max_expansions\":50,\"fuzzy_transpositions\":true,\"lenient\":false,\"zero_terms_query\":\"NONE\",\"auto_generate_synonyms_phrase_query\":true,\"boost\":1.0}}}],\"adjust_pure_negative\":true,\"boost\":1.0}}],\"filter\":[{\"bool\":{\"should\":[{\"term\":{\"permissions\":{\"value\":\"Group:790c27b4-54c9-4be6-a05e-25b326461eae\",\"boost\":1.0}}}],\"adjust_pure_negative\":true,\"boost\":1.0}}],\"adjust_pure_negative\":true,\"boost\":1.0}},\"_source\":{\"includes\":[\"isBaseProduct\",\"baseProductSystemId\",\"variantSystemIds\"],\"excludes\":[]},\"sort\":[{\"_score\":{\"order\":\"desc\"}},{\"name.keyword\":{\"order\":\"asc\"}},{\"articleNumber\":{\"order\":\"asc\"}}]}}]", "cluster.uuid": "7LVyl6TCTEyzval2BPSKqw", "node.id": "zBiq_ksQQo6_N3jT2Xj9Tg" , 
2023-05-30 10:14:18 "stacktrace": ["org.elasticsearch.transport.RemoteTransportException: [d194c7a34469][172.18.0.5:9300][indices:data/read/search[phase/query]]",
2023-05-30 10:14:18 "Caused by: org.elasticsearch.index.query.QueryShardException: [match] analyzer [synonymAnalyzer] not found",
2023-05-30 10:14:18 "at org.elasticsearch.index.query.MatchQueryBuilder.doToQuery(MatchQueryBuilder.java:408) ~[elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.index.query.AbstractQueryBuilder.toQuery(AbstractQueryBuilder.java:99) ~[elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.index.query.BoolQueryBuilder.addBooleanClauses(BoolQueryBuilder.java:394) ~[elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.index.query.BoolQueryBuilder.doToQuery(BoolQueryBuilder.java:380) ~[elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.index.query.AbstractQueryBuilder.toQuery(AbstractQueryBuilder.java:99) ~[elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.index.query.BoolQueryBuilder.addBooleanClauses(BoolQueryBuilder.java:394) ~[elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.index.query.BoolQueryBuilder.doToQuery(BoolQueryBuilder.java:378) ~[elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.index.query.AbstractQueryBuilder.toQuery(AbstractQueryBuilder.java:99) ~[elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.index.query.QueryShardContext.lambda$toQuery$1(QueryShardContext.java:334) ~[elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.index.query.QueryShardContext.toQuery(QueryShardContext.java:346) ~[elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.index.query.QueryShardContext.toQuery(QueryShardContext.java:333) ~[elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.search.SearchService.parseSource(SearchService.java:758) ~[elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.search.SearchService.createContext(SearchService.java:600) ~[elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:554) ~[elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:351) ~[elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.search.SearchService.lambda$executeQueryPhase$1(SearchService.java:343) ~[elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.action.ActionListener.lambda$map$2(ActionListener.java:146) ~[elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.action.ActionListener$1.onResponse(ActionListener.java:63) [elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.action.ActionRunnable.lambda$supply$0(ActionRunnable.java:58) [elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.action.ActionRunnable$2.doRun(ActionRunnable.java:73) [elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:44) [elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:692) [elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]",
2023-05-30 10:14:18 "at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]",
2023-05-30 10:14:18 "at java.lang.Thread.run(Thread.java:830) [?:?]"] }
2023-05-30 10:14:18 {"type": "server", "timestamp": "2023-05-30T08:14:18,138Z", "level": "DEBUG", "component": "o.e.a.s.TransportSearchAction", "cluster.name": "docker-cluster", "node.name": "d194c7a34469", "message": "All shards failed for phase: [query]", "cluster.uuid": "7LVyl6TCTEyzval2BPSKqw", "node.id": "zBiq_ksQQo6_N3jT2Xj9Tg" , 
2023-05-30 10:14:18 "stacktrace": ["org.elasticsearch.index.query.QueryShardException: [match] analyzer [synonymAnalyzer] not found",
2023-05-30 10:14:18 "at org.elasticsearch.index.query.MatchQueryBuilder.doToQuery(MatchQueryBuilder.java:408) ~[elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.index.query.AbstractQueryBuilder.toQuery(AbstractQueryBuilder.java:99) ~[elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.index.query.BoolQueryBuilder.addBooleanClauses(BoolQueryBuilder.java:394) ~[elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.index.query.BoolQueryBuilder.doToQuery(BoolQueryBuilder.java:380) ~[elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.index.query.AbstractQueryBuilder.toQuery(AbstractQueryBuilder.java:99) ~[elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.index.query.BoolQueryBuilder.addBooleanClauses(BoolQueryBuilder.java:394) ~[elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.index.query.BoolQueryBuilder.doToQuery(BoolQueryBuilder.java:378) ~[elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.index.query.AbstractQueryBuilder.toQuery(AbstractQueryBuilder.java:99) ~[elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.index.query.QueryShardContext.lambda$toQuery$1(QueryShardContext.java:334) ~[elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.index.query.QueryShardContext.toQuery(QueryShardContext.java:346) ~[elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.index.query.QueryShardContext.toQuery(QueryShardContext.java:333) ~[elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.search.SearchService.parseSource(SearchService.java:758) ~[elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.search.SearchService.createContext(SearchService.java:600) ~[elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:554) ~[elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:351) ~[elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.search.SearchService.lambda$executeQueryPhase$1(SearchService.java:343) ~[elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.action.ActionListener.lambda$map$2(ActionListener.java:146) ~[elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.action.ActionListener$1.onResponse(ActionListener.java:63) [elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.action.ActionRunnable.lambda$supply$0(ActionRunnable.java:58) [elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.action.ActionRunnable$2.doRun(ActionRunnable.java:73) [elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:44) [elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:692) [elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-7.6.2.jar:7.6.2]",
2023-05-30 10:14:18 "at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]",
2023-05-30 10:14:18 "at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]",
2023-05-30 10:14:18 "at java.lang.Thread.run(Thread.java:830) [?:?]"] }

I don’t see any errors in synonymserver container.

The compose file I’m using is the default one from the tutorial and I’m currently using Docker Desktop v4.19.0.

# Docker compose below sets up the containers needed to run Litium locally
# Same as https://docs.litium.com/documentation/get-started/shared-dependencies
# With additional containers for SQL Server and Mailhog

version: '3'
services:
  dnsresolver:
    # https://github.com/cytopia/docker-bind
    image: cytopia/bind:stable-0.28
    container_name: dnsresolver
    ports:
    - "53:53/tcp"
    - "53:53/udp"
    environment: 
    - DNS_CNAME=*.localtest.me=host.docker.internal
    - DNS_FORWARDER=192.168.65.5
    dns: 192.168.65.5
    restart: unless-stopped
     ## After update of docker desktop changing from 192.168.65.5 to 192.168.65.7 may be needed.

  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.6.2
    container_name: elasticsearch
    depends_on:
    - dnsresolver
    dns: 
    - 192.168.65.2
    restart: unless-stopped
    ports:
    - "9200:9200"
    environment:
    - discovery.type=single-node
    # Allocate 2GB RAM instead of the default 512MB
    # comment out the line below for additional memory allocation
    # - "ES_JAVA_OPTS=-Xms2g -Xmx2g"
    volumes:
    - ./volumes/elasticsearch/data:/usr/share/elasticsearch/data
    entrypoint: 
    - /bin/sh
    - -c
    # The accelerator implementation of Elasticsearch require the analysis-dynamic-synonym.
    # The plugin refreshes the list of synonyms in Elasticsearch every minute allowing synonyms 
    # to be added/modified in Litium backoffice and updated in Elasticsearch without downtime.
    - "./bin/elasticsearch-plugin list | grep -q analysis-dynamic-synonym || ./bin/elasticsearch-plugin install -b https://github.com/Tasteful/elasticsearch-analysis-dynamic-synonym/releases/download/v7.6.2/elasticsearch-analysis-dynamic-synonym.zip; /usr/local/bin/docker-entrypoint.sh"
  
  kibana:
    # The Kibana image tries, by default, to connect to a host/container called elasticsearch.
    image: docker.elastic.co/kibana/kibana:7.6.2
    container_name: kibana
    depends_on:
    - elasticsearch
    restart: unless-stopped
    ports:
    - "5601:5601"

  synonymserver:
    # Synonym server to provide elasticsearch with synonyms without needing that the customer application is running.
    image: registry.litium.cloud/apps/synonym-server:1.2.0
    container_name: synonymserver
    restart: unless-stopped
    ports:
    - "9210:80"
    environment:
    - DataFolder=/app_data
    volumes:
    - ./volumes/synonymserver/data:/app_data

  redis:
    image: redis:5.0.5-alpine
    container_name: redis
    restart: unless-stopped
    ports:
    - "6379:6379"

  sqlserver:
    image: mcr.microsoft.com/mssql/server:2019-latest
    environment:
      - SA_PASSWORD=Pass@word
      - ACCEPT_EULA=Y
    restart: unless-stopped
    ports:
      # Make the SQL Container available on port 5434 to not conflict with a previously installed local SQL instance.
      # If you do not have SQL Server installed you can use 1433:1433 as mapping and skip port number in connectionstrings.
      - "5434:1433"
    volumes:
      # Map [local directory:container directory] - this is so that db/log files are
      # stored on the "host" (your local computer, outside of container) and thereby 
      # persisted when container restarts.
      # by starting local path with "." it gets relative to current folder, meaning that the database
      # files will be on your computer in the same directory as you have this docker-compose.yaml file
      - ./data/mssql/data:/var/opt/mssql/data
      - ./data/mssql/log:/var/opt/mssql/log
    entrypoint: 
      # Due to an issue with the sqlserver image, permissions to db-files may be lost on container restart
      # by using the specific permissions_check entrypoint you assert that permissions are set on every restart
      - /bin/sh
      - -c
      - "/opt/mssql/bin/permissions_check.sh && /opt/mssql/bin/sqlservr"

  mailhog:
    image: mailhog/mailhog:latest
    restart: unless-stopped
    logging:
      driver: 'none'
    ports:
      - 1025:1025 # SMTP-server
      - 8025:8025 # Web UI

I had issues with later versions of dockerdesktop so I rolled back to one that worked (currently 4.13). In the dockercompose file, there is a suggestion to change the dns-reslolvers ip address from 5 - 7. Have you tried that? My money is on the communications inside docker, where elastic has issues communicating with synonym-server.

I think that you could find even more useful errors in the elastic logs that will narrow your search, I guess that the stacktrace you replied with is only the tip of the iceberg.

I had some issues with elasticsearch, not sure if same as yours, but this helped.

Dynamic synonyms was not installed, changing dns for elasticsearch as suggested by the comment from 192.168.0.2 to 192.168.0.7 and same change for DNS_FORWARDER. Commenting out as suggeste din URKL beklow also worked, but not sure of implications.

From The app could not be installed - again (DirectPay) changed hosts and LitiumApi__ApiUrl .

In appsettings.json changed to:

“Server”: “http://kubernetes.docker.internal:9210”,

Could also be to disk space, if errors in logs in docker maybe reduce memory use, can be sent via Kibana, something like:

PUT _cluster/settings
{
“transient”: {
“cluster.routing.allocation.disk.watermark.low”: “30mb”,
“cluster.routing.allocation.disk.watermark.high”: “20mb”,
“cluster.routing.allocation.disk.watermark.flood_stage”: “10mb”,
“cluster.info.update.interval”: “1m”
}
}

PUT /_all/_settings
{
“index.blocks.read_only_allow_delete”: null
}

I also got error:

2023-05-04 10:56:36.8015 [App:01] [1a7739cb79a53718c3194e258c701e69] [ERROR] [.NET ThreadPool Worker] Litium.Search.Indexing.IndexQueueService - Error in building index document for Litium.Accelerator.Search.ProductDocument with c5595d0a-b159-492e-98e8-610525de3aa3 and “Index”, {“id”:“ProductDocument:c5595d0a-b159-492e-98e8-610525de3aa3”, “primaryTerm”:2, “sequenceNumber”:70014, “version”:2155}: “Stored type System.Collections.Generic.ICollection1[[System.String, System.Private.CoreLib]], System.Private.CoreLib and requested type System.Collections.Generic.IList1[[System.String, System.Private.CoreLib]], System.Private.CoreLib does not match.” System.InvalidCastException: Stored type System.Collections.Generic.ICollection1[[System.String, System.Private.CoreLib]], System.Private.CoreLib and requested type System.Collections.Generic.IList1[[System.String, System.Private.CoreLib]], System.Private.CoreLib does not match.

Solved by patch:

// Src/Litium.Accelerator/Search/Filtering/FilterService.cs
-        public void SaveProductFilteringFields(ICollection<string> items)
+        public void SaveProductFilteringFields(IList<string> items)

Thank you for your reply! I’ve done some tests and the solution that worked was indeed to change dns IP in docker compose file to 192.168.65.7 in both dnsresolver and elasticsearch configurations. Now everything is working!

I’m attaching the updated file for future reference:

# Docker compose below sets up the containers needed to run Litium locally
# Same as https://docs.litium.com/documentation/get-started/shared-dependencies
# With additional containers for SQL Server and Mailhog

version: '3'
services:
  dnsresolver:
    # https://github.com/cytopia/docker-bind
    image: cytopia/bind:stable-0.28
    container_name: dnsresolver
    ports:
    - "53:53/tcp"
    - "53:53/udp"
    environment: 
    - DNS_CNAME=*.localtest.me=host.docker.internal
    - DNS_FORWARDER=192.168.65.7
    dns: 192.168.65.7
    restart: unless-stopped
     ## After update of docker desktop changing from 192.168.65.5 to 192.168.65.7 may be needed.

  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.6.2
    container_name: elasticsearch
    depends_on:
    - dnsresolver
    dns: 
    - 192.168.65.7
    restart: unless-stopped
    ports:
    - "9200:9200"
    environment:
    - discovery.type=single-node
    # Allocate 2GB RAM instead of the default 512MB
    # comment out the line below for additional memory allocation
    # - "ES_JAVA_OPTS=-Xms2g -Xmx2g"
    volumes:
    - ./volumes/elasticsearch/data:/usr/share/elasticsearch/data
    entrypoint: 
    - /bin/sh
    - -c
    # The accelerator implementation of Elasticsearch require the analysis-dynamic-synonym.
    # The plugin refreshes the list of synonyms in Elasticsearch every minute allowing synonyms 
    # to be added/modified in Litium backoffice and updated in Elasticsearch without downtime.
    - "./bin/elasticsearch-plugin list | grep -q analysis-dynamic-synonym || ./bin/elasticsearch-plugin install -b https://github.com/Tasteful/elasticsearch-analysis-dynamic-synonym/releases/download/v7.6.2/elasticsearch-analysis-dynamic-synonym.zip; /usr/local/bin/docker-entrypoint.sh"
  
  kibana:
    # The Kibana image tries, by default, to connect to a host/container called elasticsearch.
    image: docker.elastic.co/kibana/kibana:7.6.2
    container_name: kibana
    depends_on:
    - elasticsearch
    restart: unless-stopped
    ports:
    - "5601:5601"

  synonymserver:
    # Synonym server to provide elasticsearch with synonyms without needing that the customer application is running.
    image: registry.litium.cloud/apps/synonym-server:1.2.0
    container_name: synonymserver
    restart: unless-stopped
    ports:
    - "9210:80"
    environment:
    - DataFolder=/app_data
    volumes:
    - ./volumes/synonymserver/data:/app_data

  redis:
    image: redis:5.0.5-alpine
    container_name: redis
    restart: unless-stopped
    ports:
    - "6379:6379"

  sqlserver:
    image: mcr.microsoft.com/mssql/server:2019-latest
    environment:
      - SA_PASSWORD=Pass@word
      - ACCEPT_EULA=Y
    restart: unless-stopped
    ports:
      # Make the SQL Container available on port 5434 to not conflict with a previously installed local SQL instance.
      # If you do not have SQL Server installed you can use 1433:1433 as mapping and skip port number in connectionstrings.
      - "5434:1433"
    volumes:
      # Map [local directory:container directory] - this is so that db/log files are
      # stored on the "host" (your local computer, outside of container) and thereby 
      # persisted when container restarts.
      # by starting local path with "." it gets relative to current folder, meaning that the database
      # files will be on your computer in the same directory as you have this docker-compose.yaml file
      - ./data/mssql/data:/var/opt/mssql/data
      - ./data/mssql/log:/var/opt/mssql/log
    entrypoint: 
      # Due to an issue with the sqlserver image, permissions to db-files may be lost on container restart
      # by using the specific permissions_check entrypoint you assert that permissions are set on every restart
      - /bin/sh
      - -c
      - "/opt/mssql/bin/permissions_check.sh && /opt/mssql/bin/sqlservr"

  mailhog:
    image: mailhog/mailhog:latest
    restart: unless-stopped
    logging:
      driver: 'none'
    ports:
      - 1025:1025 # SMTP-server
      - 8025:8025 # Web UI

I’ve also had the issue with type mismatch but I’ve changed the Get method instead:

public IList<string> GetProductFilteringFields()
        {
            return _settingsService.Get<ICollection<string>>(_key).ToList() ?? new List<string>();
        }

I don’t know which is better. :grin:

2 Likes

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.