-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trunk-5680 - For Debug reasons - Refactor getSimilarPeople to use Lucene #3116
Conversation
6759c09
to
b90e31d
Compare
you can get the commits squashed here!! |
int maxResults = HibernatePersonDAO.getMaximumSearchResults(); | ||
|
||
LuceneQuery<PersonName> luceneQuery = personLuceneQuery.getSoundexPersonNameQuery(query, 0, true, "M");; | ||
//getSoundexPersonNameQuery(query,birthyear, false, gender); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove commented code
temp_OutSource_Operation(name); | ||
//q.append("(").append(" soundex(pname.givenName) = soundex(:n1)").append( | ||
// " or soundex(pname.middleName) = soundex(:n1)").append(" or soundex(pname.familyName) = soundex(:n1) ") | ||
// .append(" or soundex(pname.familyName2) = soundex(:n1) ").append(")"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove commented code
//(year(p.birthdate) between " + (birthyear - 1) + " and " + (birthyear + 1) | ||
// + " or p.birthdate is null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove commented code
// luceneQuery.include("voided", false); | ||
// luceneQuery.include("person.voided", false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if block is empty. You can remove it
|
||
if(gender != null) { | ||
String[] searchedGenders = new String[] {gender, ""}; | ||
//luceneQuery.include("person.gender", searchedGenders); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove commented code
Hi,
*@dilanthas * the PR only serves for the matter of discussion (it's not working).
So I will come back to these comments once the real issue is fixed. Thanks
for your effort.
Link you discussion: https://talk.openmrs.org/t/soundex-search-in-lucenequeries/26068/13
@rkorytkowski any idea having a look to the current state of the code why the analyzer does not find any result?
Dilantha Silva <notifications@github.com> schrieb am Mi., 15. Jan. 2020,
11:19:
… ***@***.**** requested changes on this pull request.
------------------------------
In api/src/main/java/org/openmrs/api/db/hibernate/HibernatePersonDAO.java
<#3116 (comment)>:
> @@ -72,6 +72,20 @@ public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
+
+ private ListPart<Object[]> temp_OutSource_Operation(String name) {
+ PersonLuceneQuery personLuceneQuery = new PersonLuceneQuery(sessionFactory);
+ String query = LuceneQuery.escapeQuery(name);
+ int maxResults = HibernatePersonDAO.getMaximumSearchResults();
+
+ LuceneQuery<PersonName> luceneQuery = personLuceneQuery.getSoundexPersonNameQuery(query, 0, true, "M");;
+ //getSoundexPersonNameQuery(query,birthyear, false, gender);
Please remove commented code
------------------------------
In api/src/main/java/org/openmrs/api/db/hibernate/HibernatePersonDAO.java
<#3116 (comment)>:
> if (names.length == 1) {
- q.append("(").append(" soundex(pname.givenName) = soundex(:n1)").append(
- " or soundex(pname.middleName) = soundex(:n1)").append(" or soundex(pname.familyName) = soundex(:n1) ")
- .append(" or soundex(pname.familyName2) = soundex(:n1) ").append(")");
+ temp_OutSource_Operation(name);
+ //q.append("(").append(" soundex(pname.givenName) = soundex(:n1)").append(
+ // " or soundex(pname.middleName) = soundex(:n1)").append(" or soundex(pname.familyName) = soundex(:n1) ")
+ // .append(" or soundex(pname.familyName2) = soundex(:n1) ").append(")");
Please remove commented code
------------------------------
In api/src/main/java/org/openmrs/api/db/hibernate/PersonLuceneQuery.java
<#3116 (comment)>:
> + //(year(p.birthdate) between " + (birthyear - 1) + " and " + (birthyear + 1)
+ // + " or p.birthdate is null)
Please remove commented code
------------------------------
In api/src/main/java/org/openmrs/api/db/hibernate/PersonLuceneQuery.java
<#3116 (comment)>:
> + // luceneQuery.include("voided", false);
+ // luceneQuery.include("person.voided", false);
This if block is empty. You can remove it
------------------------------
In api/src/main/java/org/openmrs/api/db/hibernate/PersonLuceneQuery.java
<#3116 (comment)>:
> + // + " or p.birthdate is null)
+ String dateQuery = " AND person.birthdate: [" + (birthyear - 1) + " TO " + (birthyear + 1) + "]";
+ completeQuery+= dateQuery;
+ }
+
+ LuceneQuery<PersonName> luceneQuery = LuceneQuery
+ .newQuery(PersonName.class, sessionFactory.getCurrentSession(), query, fields).useOrQueryParser();
+
+ if (!includeVoided) {
+ // luceneQuery.include("voided", false);
+ // luceneQuery.include("person.voided", false);
+ }
+
+ if(gender != null) {
+ String[] searchedGenders = new String[] {gender, ""};
+ //luceneQuery.include("person.gender", searchedGenders);
Please remove commented code
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#3116?email_source=notifications&email_token=AAMEOAB32HFJU5E7TY2CNUTQ53PKBA5CNFSM4KGIAC6KYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCRZYFBA#pullrequestreview-343114372>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMEOABKMUREDRIMZEKL23TQ53PKBANCNFSM4KGIAC6A>
.
|
@fruether, I don't see anything obvious. I'll run your code once I have some spare cycles. Probably next week. |
Nice :) You can remove the comments. |
@saadkhaleeq610 why should the comment be removed? Comments are added with the purpose of making the source code easier for human to understand, and are generally ignored by compilers and interpreters. I anticipated you to talk about about the Travis CI failure in this case. |
@jwnasambu this PR does not have the intend to be merged into the code base. It only has the reason to help the discussion in talk. That is why the "comments" can be ignored for now. They will be fixed once the code is working. Then I will do the beautification regarding adding source code comments, variable names, code squashing and so on. Once I figured with the help of @rkorytkowski out what is missing, I will recreate the PR with . the previous comments taken into account :) |
@@ -84,6 +98,7 @@ public void setSessionFactory(SessionFactory sessionFactory) { | |||
if (birthyear == null) { | |||
birthyear = 0; | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unnecessary line here
|
||
// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is empty, please remove it :)
.param("encoder", "Soundex") | ||
.param("inject", "true"); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unnecessary blank line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sumangala028 thanks for your review. But as I pointed out above: The code of this PR does not work. So we should focus on making the code work and then after that is established we can focus on more formal and beautification issues.
if you want to participate helping to make this code work: https://talk.openmrs.org/t/soundex-search-in-lucenequeries/26068/13
Otherwise I think the energy could be rather used on different reviews.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see... thanks for pointing me to the discussion of this issue. Yes, the beautification issues can be pushed back till the code is fixed.
@rkorytkowski Is there a time slot during Februrary where you may have some spare time to run the code? Any hint what I can do/try out while waiting for feedback? |
Hi @fruether , nice work on this. My recommendation would be to write some tests (parallel to the patient search test I wrote, which checks whether accent flattening works). I think that will help clarify the problem, and also provide a nice entry point for debugging. |
051ec5c
to
d1ba85e
Compare
Description of what I changed
This PR is mainly to discuss the subject in the following thread: https://talk.openmrs.org/t/soundex-search-in-lucenequeries/26068/10
So please stop focusing on beautification/formal issues of this PR: It is not intended to be merged into the code base. Focus right now is to make the code work. After!!!!!!!!!, it is working I will of cause re-work on the code and make it match the formal and quality criteria. So please focus your review effort on making it work or spend the time on another PR. Thank you!
Issue I worked on
see https://issues.openmrs.org/browse/Trunk-5680
Checklist: I completed these to help reviewers :)
My pull request only contains ONE single commit
(the number above, next to the 'Commits' tab is 1).
No? -> read here on how to squash multiple commits into one
My IDE is configured to follow the code style of this project.
No? Unsure? -> configure your IDE, format the code and add the changes with
git add . && git commit --amend
I have added tests to cover my changes. (If you refactored
existing code that was well tested you do not have to add tests)
No? -> write tests and add them to this commit
git add . && git commit --amend
I ran
mvn clean package
right before creating this pull request andadded all formatting changes to my commit.
No? -> execute above command
All new and existing tests passed.
No? -> figure out why and add the fix to your commit. It is your responsibility to make sure your code works.
My pull request is based on the latest changes of the master branch.
No? Unsure? -> execute command
git pull --rebase upstream master