Issue with Identifier length while searching

We have one identifier with length of 21 characters. When we are searching with this identifier we are not getting the result even though there is patient with this identifier but when we remove one char from the identifier and search, we are getting the results.

@angshuonline, @darius, @shruthipitta could anyone tell us is there any limitation on identifier length to search?

Is this in registration screen? Do you see any error in the network call? @mahitha

There is no any error in the network call, the result is empty list. This is the message we are getting when we are searching with more than 20 characters in identifier field.

I peeked at the code briefly and I didn’t see any limit of 20 characters.

To investigate this, you might try changing the test data for this file to have a longer identifier, and then run the test:

I ran the test cases by changing the test data. Till 20 characters test cases were passing, if the identifier length exceeds more than 20 characters, tests are failing.

1 Like

This is causing the issue. Since its maxGramSize is 20 its not able to search when length is beyond that. This happening because we use AnywhereAnalyzer in Bahmni core API:


@shruthipitta is there a reason that we had to write a custom Bahmni lucene query for this and we couldn’t leverage what’s built in to openmrs-core?

Or rather: would we be able to preserve our expected behavior just by using OpenMRS code?

@darius I had a quick look at the code and I dont see any obvious reason as to why we implemented it in Bahmni instead of using the OpenMRS query. I think we have to get rid of the redundant code. However even the Openmrs API should have the same issue, isn’t it? Am I missing something?

Yes, I think people just never came across it yet.

@ningosi this is typically the kind of discussion that might affect BAH-273. As in: making an inventory of all places that involve Lucene searches.

1 Like

You’re right @shruthipitta I hadn’t noticed that the first link you gave was to openmrs-core code. Possible approaches that occur to me off the top of my head:

  1. Make the max length longer in openmrs-core. (I assume there’s a resource cost for this.)
    • could also introduce a similar analyzer with a longer max-length in a Bahmni-specific module. (Same resource cost, but we could decide to do this without any larger discussion)
  2. Stop supporting wildcard identifier searches longer than 20 characters. If the input is too long, just do an exact search.

My (uninformed) vote is for 2.

@mahitha would this limitation be okay for your implementation project?

PS- In fact OpenMRS prefers not to support wildcard searches on identifiers (because identifiers are supposed to be meaningless and wildcard searches make it easier to select the wrong patient).

Thanks for asking. We are okay to have this limitation.

@mahitha can you and your team please create a JIRA ticket for this?

this is JIRA ticket link