Need help with Elastic search fix

We are working on fixing the elastic search as specified int he Jira Ticket - https://issues.openmrs.org/browse/AO-5. However, we are not quite understanding a couple of the recommended fixing procedures. In Proposed Search algorithm for Add-On Index, under ‘Whats the solution’ it is recommended to set the ‘Name field’ as ‘Not Analyzed’. The part in which the confusion arises is where they are referring to ‘name field’. The ElasticSearch seems to be taking in a tokenized query in its search function, so we are not quite sure where the query is getting tokenized and where this “name field” is located. We also are unsure what it means to set the field to “Not Analyzed”. Where is the name field located, and how do we set it to “Not Analyzed”?

cc @reubenv and @dkayiwa

Additionally, order for this elastic search to work properly will we need additional add-ons installed for the search to display them in its query? How do we access these and if we need to install them how would we go about doing so?

We are getting messages like:

2019-03-28 11:12:53.167  INFO 2699 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring FrameworkServlet 'dispatcherServlet'
2019-03-28 11:12:53.168  INFO 2699 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization started
2019-03-28 11:12:53.224  INFO 2699 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization completed in 56 ms
2019-03-28 11:17:32.910  WARN 2699 --- [nio-8080-exec-5] o.o.addonindex.service.IndexingService   : Could not find addon org.openmrs.module.idgen in index
2019-03-28 11:17:32.917  WARN 2699 --- [nio-8080-exec-5] o.o.addonindex.service.IndexingService   : Could not find addon org.openmrs.module.htmlformentry in index
2019-03-28 11:17:32.975  WARN 2699 --- [nio-8080-exec-5] o.o.addonindex.service.IndexingService   : Could not find addon org.openmrs.module.xforms in index
2019-03-28 11:17:33.012  WARN 2699 --- [nio-8080-exec-5] o.o.addonindex.service.IndexingService   : Could not find addon org.openmrs.module.reporting in index
2019-03-28 11:17:33.022  WARN 2699 --- [nio-8080-exec-5] o.o.addonindex.service.IndexingService   : Could not find addon org.openmrs.module.admin-ui-module in index
2019-03-28 11:17:33.043  WARN 2699 --- [nio-8080-exec-5] o.o.addonindex.service.IndexingService   : Could not find addon org.openmrs.module.legacy-ui-module in index
2019-03-28 11:17:33.070  WARN 2699 --- [nio-8080-exec-5] o.o.addonindex.service.IndexingService   : Could not find addon org.openmrs.module.registration-core-module in index

The different fields and their configurations are mentioned in this file. For more information on how to set it to not analyzed, check this and this out. Also, the tokenization part is taken care of by elasticsearch and not by the AddOns application.

You don’t need any additonal AddOns installed, just run the AddOns application and keep it running for a while. AddOns will automatically index all the modules and their details for you in the background. In the above snippet, you get the errors because AddOns had not yet indexed those modules and their details yet when you tried to fetch its details.

Please Note: You internet connection needs to be working for AddOns to be able to index the modules successfully.

You don’t need any additonal AddOns installed, just run the AddOns application and keep it running for a while. AddOns will automatically index all the modules and their details for you in the background.

When you refer to the AddOns application, are you referring to the openmrs-contrib-addonindex repository or openmrs-owa-addonmanager repository? We are only using the former. I have left the server running for about 30 minutes, and no AddOns have displayed, either on their own or after a search is performed.

Under indexing status, I am receiving 212 errors and 0 successes. Here is one of these errors:

{
  "indexingNow": false,
  "lastIndexed": "2019-03-29T09:15:15.297-05:00",
  "startedIndexing": null,
  "summary": null,
  "error": {
    "cause": null,
    "stackTrace": [
      {
        "methodName": "hasLength",
        "fileName": "Assert.java",
        "lineNumber": 157,
        "className": "org.springframework.util.Assert",
        "nativeMethod": false
      },
      {
        "methodName": "<init>",
        "fileName": "BasicAuthorizationInterceptor.java",
        "lineNumber": 51,
        "className": "org.springframework.http.client.support.BasicAuthorizationInterceptor",
        "nativeMethod": false
      },
      {
        "methodName": "basicAuthorization",
        "fileName": "RestTemplateBuilder.java",
        "lineNumber": 390,
        "className": "org.springframework.boot.web.client.RestTemplateBuilder",
        "nativeMethod": false
      },
      {
        "methodName": "getInfoAndVersionsFor",
        "fileName": "Bintray.java",
        "lineNumber": 62,
        "className": "org.openmrs.addonindex.backend.Bintray",
        "nativeMethod": false
      },
      {
        "methodName": "getDetailsAndIndex",
        "fileName": "FetchDetailsToIndex.java",
        "lineNumber": 107,
        "className": "org.openmrs.addonindex.scheduled.FetchDetailsToIndex",
        "nativeMethod": false
      },
      {
        "methodName": "run",
        "fileName": "FetchDetailsToIndex.java",
        "lineNumber": 91,
        "className": "org.openmrs.addonindex.scheduled.FetchDetailsToIndex",
        "nativeMethod": false
      },
      {
        "methodName": "invoke0",
        "fileName": "NativeMethodAccessorImpl.java",
        "lineNumber": -2,
        "className": "sun.reflect.NativeMethodAccessorImpl",
        "nativeMethod": true
      },
      {
        "methodName": "invoke",
        "fileName": "NativeMethodAccessorImpl.java",
        "lineNumber": 62,
        "className": "sun.reflect.NativeMethodAccessorImpl",
        "nativeMethod": false
      },
      {
        "methodName": "invoke",
        "fileName": "DelegatingMethodAccessorImpl.java",
        "lineNumber": 43,
        "className": "sun.reflect.DelegatingMethodAccessorImpl",
        "nativeMethod": false
      },
      {
        "methodName": "invoke",
        "fileName": "Method.java",
        "lineNumber": 498,
        "className": "java.lang.reflect.Method",
        "nativeMethod": false
      },
      {
        "methodName": "run",
        "fileName": "ScheduledMethodRunnable.java",
        "lineNumber": 65,
        "className": "org.springframework.scheduling.support.ScheduledMethodRunnable",
        "nativeMethod": false
      },
      {
        "methodName": "run",
        "fileName": "DelegatingErrorHandlingRunnable.java",
        "lineNumber": 54,
        "className": "org.springframework.scheduling.support.DelegatingErrorHandlingRunnable",
        "nativeMethod": false
      },
      {
        "methodName": "call",
        "fileName": "Executors.java",
        "lineNumber": 511,
        "className": "java.util.concurrent.Executors$RunnableAdapter",
        "nativeMethod": false
      },
      {
        "methodName": "runAndReset",
        "fileName": "FutureTask.java",
        "lineNumber": 308,
        "className": "java.util.concurrent.FutureTask",
        "nativeMethod": false
      },
      {
        "methodName": "access$301",
        "fileName": "ScheduledThreadPoolExecutor.java",
        "lineNumber": 180,
        "className": "java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask",
        "nativeMethod": false
      },
      {
        "methodName": "run",
        "fileName": "ScheduledThreadPoolExecutor.java",
        "lineNumber": 294,
        "className": "java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask",
        "nativeMethod": false
      },
      {
        "methodName": "runWorker",
        "fileName": "ThreadPoolExecutor.java",
        "lineNumber": 1149,
        "className": "java.util.concurrent.ThreadPoolExecutor",
        "nativeMethod": false
      },
      {
        "methodName": "run",
        "fileName": "ThreadPoolExecutor.java",
        "lineNumber": 624,
        "className": "java.util.concurrent.ThreadPoolExecutor$Worker",
        "nativeMethod": false
      },
      {
        "methodName": "run",
        "fileName": "Thread.java",
        "lineNumber": 748,
        "className": "java.lang.Thread",
        "nativeMethod": false
      }
    ],
    "message": "Username must not be empty",
    "localizedMessage": "Username must not be empty",
    "suppressed": []
  }
}

Here are the console warnings and errors:

2019-03-29 09:15:15.980 ERROR 2728 --- [pool-2-thread-1] org.openmrs.addonindex.backend.Bintray   : You need to specify the bintray.username and bintray.api_key configuration settings
2019-03-29 09:15:15.980 ERROR 2728 --- [pool-2-thread-1] o.o.a.scheduled.FetchDetailsToIndex      : Error indexing org.openmrs.module.emr-monitor-module

java.lang.IllegalArgumentException: Username must not be empty
        at org.springframework.util.Assert.hasLength(Assert.java:157) ~[spring-core-4.3.18.RELEASE.jar!/:4.3.18.RELEASE]
        at org.springframework.http.client.support.BasicAuthorizationInterceptor.<init>(BasicAuthorizationInterceptor.java:51) ~[spring-web-4.3.18.RELEASE.jar!/:4.3.18.RELEASE]
        at org.springframework.boot.web.client.RestTemplateBuilder.basicAuthorization(RestTemplateBuilder.java:390) ~[spring-boot-1.5.14.RELEASE.jar!/:1.5.14.RELEASE]
        at org.openmrs.addonindex.backend.Bintray.getInfoAndVersionsFor(Bintray.java:62) ~[classes!/:1.0-SNAPSHOT]
        at org.openmrs.addonindex.scheduled.FetchDetailsToIndex.getDetailsAndIndex(FetchDetailsToIndex.java:107) [classes!/:1.0-SNAPSHOT]
        at org.openmrs.addonindex.scheduled.FetchDetailsToIndex.run(FetchDetailsToIndex.java:91) [classes!/:1.0-SNAPSHOT]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_171]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_171]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_171]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_171]
        at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65) [spring-context-4.3.18.RELEASE.jar!/:4.3.18.RELEASE]
        at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) [spring-context-4.3.18.RELEASE.jar!/:4.3.18.RELEASE]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_171]
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [na:1.8.0_171]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_171]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [na:1.8.0_171]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_171]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_171]
        at java.lang.Thread.run(Thread.java:748) [na:1.8.0_171]

2019-03-29 09:16:32.415  INFO 2728 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring FrameworkServlet 'dispatcherServlet'
2019-03-29 09:16:32.422  INFO 2728 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization started
2019-03-29 09:16:32.484  INFO 2728 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization completed in 61 ms
2019-03-29 09:16:33.543  WARN 2728 --- [nio-8080-exec-7] o.o.addonindex.service.IndexingService   : Could not find addon org.openmrs.module.idgen in index
2019-03-29 09:16:33.584  WARN 2728 --- [nio-8080-exec-7] o.o.addonindex.service.IndexingService   : Could not find addon org.openmrs.module.htmlformentry in index
2019-03-29 09:16:33.607  WARN 2728 --- [nio-8080-exec-7] o.o.addonindex.service.IndexingService   : Could not find addon org.openmrs.module.xforms in index
2019-03-29 09:16:33.748  WARN 2728 --- [nio-8080-exec-7] o.o.addonindex.service.IndexingService   : Could not find addon org.openmrs.module.reporting in index
2019-03-29 09:16:33.786  WARN 2728 --- [nio-8080-exec-7] o.o.addonindex.service.IndexingService   : Could not find addon org.openmrs.module.admin-ui-module in index
2019-03-29 09:16:33.813  WARN 2728 --- [nio-8080-exec-7] o.o.addonindex.service.IndexingService   : Could not find addon org.openmrs.module.legacy-ui-module in index
2019-03-29 09:16:33.854  WARN 2728 --- [nio-8080-exec-7] o.o.addonindex.service.IndexingService   : Could not find addon org.openmrs.module.registration-core-module in index
2019-03-29 09:38:40.769  WARN 2728 --- [io-8080-exec-10] o.o.addonindex.service.IndexingService   : Could not find addon org.openmrs.module.idgen in index
2019-03-29 09:38:40.791  WARN 2728 --- [io-8080-exec-10] o.o.addonindex.service.IndexingService   : Could not find addon org.openmrs.module.htmlformentry in index
2019-03-29 09:38:40.810  WARN 2728 --- [io-8080-exec-10] o.o.addonindex.service.IndexingService   : Could not find addon org.openmrs.module.xforms in index
2019-03-29 09:38:40.853  WARN 2728 --- [io-8080-exec-10] o.o.addonindex.service.IndexingService   : Could not find addon org.openmrs.module.reporting in index
2019-03-29 09:38:40.890  WARN 2728 --- [io-8080-exec-10] o.o.addonindex.service.IndexingService   : Could not find addon org.openmrs.module.admin-ui-module in index
2019-03-29 09:38:40.934  WARN 2728 --- [io-8080-exec-10] o.o.addonindex.service.IndexingService   : Could not find addon org.openmrs.module.legacy-ui-module in index
2019-03-29 09:38:40.971  WARN 2728 --- [io-8080-exec-10] o.o.addonindex.service.IndexingService   : Could not find addon org.openmrs.module.registration-core-module in index

I can also ensure that there is internet connection.

@challett3 Ah I see, the error that you get is pretty easy to fix. You just need to put in your Bintray(create one, if you don’t have one yet) account’s username and password in this location and restart the server.

I have created a bintray account and added its details in the file you specified, saved, rebuilt, and restarted the server. This has resolved the above errors, but I am now receiving a new one: a 401 unauthorized error over each of the add-ons. Here is one such error:

2019-04-05 09:45:27.905 ERROR 4094 --- [pool-2-thread-1] o.o.a.scheduled.FetchDetailsToIndex      : Error indexing org.openmrs.module.emr-monitor-module

org.springframework.web.client.HttpClientErrorException: 401 Unauthorized
        at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:86) ~[spring-web-4.3.18.RELEASE.jar!/:4.3.18.RELEASE]
        at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:708) ~[spring-web-4.3.18.RELEASE.jar!/:4.3.18.RELEASE]
        at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:661) ~[spring-web-4.3.18.RELEASE.jar!/:4.3.18.RELEASE]
        at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:621) ~[spring-web-4.3.18.RELEASE.jar!/:4.3.18.RELEASE]
        at org.springframework.web.client.RestTemplate.getForEntity(RestTemplate.java:320) ~[spring-web-4.3.18.RELEASE.jar!/:4.3.18.RELEASE]
        at org.openmrs.addonindex.backend.Bintray.getInfoAndVersionsFor(Bintray.java:63) ~[classes!/:1.0-SNAPSHOT]
        at org.openmrs.addonindex.scheduled.FetchDetailsToIndex.getDetailsAndIndex(FetchDetailsToIndex.java:107) [classes!/:1.0-SNAPSHOT]
        at org.openmrs.addonindex.scheduled.FetchDetailsToIndex.run(FetchDetailsToIndex.java:91) [classes!/:1.0-SNAPSHOT]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_171]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_171]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_171]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_171]
        at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65) [spring-context-4.3.18.RELEASE.jar!/:4.3.18.RELEASE]
        at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) [spring-context-4.3.18.RELEASE.jar!/:4.3.18.RELEASE]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_171]
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [na:1.8.0_171]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_171]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [na:1.8.0_171]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_171]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_171]
        at java.lang.Thread.run(Thread.java:748) [na:1.8.0_171]

Do I need to link my Bintray account to OpenMRS? Or does instead have something to do with the api_key field (which I am told is not the same as a password)?

Hello Reuben,

We have a couple questions:

Do we have to make any other changes elsewhere if we create a duplicate field? Or should we just name the duplicate name field “name” also, and ElasticSearch will look at both of them?

Hey @challett3,

I’m so sorry, I missed this post. From what I can see in the logs, it looks like your Bintray username and password have been added but you aren’t authorized to use the API(I thought even those who aren’t part of the organization could use the API but would be rate limited. Guess I was wrong about that) to fetch the data. This kinda makes sense as you aren’t part of the OpenMRS organization on Bintray. Unfortunately , I do not have the required authorization to add you to the organization but @burke or @dkayiwa can possibly help you with this. Just tell them your username on bintray and they’ll add you.

@agray I am not really sure as it has been a while since I’ve worked with elasticsearch(moreover, I haven’t tried adding duplicate fields so far, so I guess that’s something you’ll have to research online. Maybe by looking up some examples perhaps?) . That being said, have a look at this . You can make changes here to define how your search results should look.

Once again, my apologies for taking so long to respond!

@reubenv

I was recently added to the OpenMRS organization on Bintray, but I’m afraid I still receive the 401 Unauthorized error. After running through it a couple more times, I noticed a Null Pointer occurring early on:

My thought is that the 401 Error is occuring as a result of this Null Pointer, as I encountered this error when running the ElasticSearchIndexManualTest file too. Perhaps it has something to do with the client or its execute function?