You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2019/12/19 17:27:22 UTC

[GitHub] [lucene-solr] andywebb1975 opened a new pull request #1103: LUCENE-9102 add maxQueryLength option to DirectSpellChecker

andywebb1975 opened a new pull request #1103: LUCENE-9102 add maxQueryLength option to DirectSpellChecker
URL: https://github.com/apache/lucene-solr/pull/1103
 
 
   WORK IN PROGRESS - this is not ready for review
   
   <!--
   _(If you are a project committer then you may remove some/all of the following template.)_
   
   Before creating a pull request, please file an issue in the ASF Jira system for Lucene or Solr:
   
   * https://issues.apache.org/jira/projects/LUCENE
   * https://issues.apache.org/jira/projects/SOLR
   
   You will need to create an account in Jira in order to create an issue.
   
   The title of the PR should reference the Jira issue number in the form:
   
   * LUCENE-####: <short description of problem or changes>
   * SOLR-####: <short description of problem or changes>
   
   LUCENE and SOLR must be fully capitalized. A short description helps people scanning pull requests for items they can work on.
   
   Properly referencing the issue in the title ensures that Jira is correctly updated with code review comments and commits. -->
   
   
   # Description
   
   Please provide a short description of the changes you're making with this pull request.
   
   # Solution
   
   Please provide a short description of the approach taken to implement your solution.
   
   # Tests
   
   Please describe the tests you've developed or run to confirm this patch implements the feature or solves the problem.
   
   # Checklist
   
   Please review the following and check all that apply:
   
   - [ ] I have reviewed the guidelines for [How to Contribute](https://wiki.apache.org/solr/HowToContribute) and my code conforms to the standards described there to the best of my ability.
   - [ ] I have created a Jira issue and added the issue ID to my pull request title.
   - [ ] I have given Solr maintainers [access](https://help.github.com/en/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork) to contribute to my PR branch. (optional but recommended)
   - [ ] I have developed this patch against the `master` branch.
   - [ ] I have run `ant precommit` and the appropriate test suite.
   - [ ] I have added tests for my changes.
   - [ ] I have added documentation for the [Ref Guide](https://github.com/apache/lucene-solr/tree/master/solr/solr-ref-guide) (for Solr changes only).
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene-solr] andywebb1975 commented on a change in pull request #1103: LUCENE-9102 add maxQueryLength option to DirectSpellChecker

Posted by GitBox <gi...@apache.org>.
andywebb1975 commented on a change in pull request #1103: LUCENE-9102 add maxQueryLength option to DirectSpellChecker
URL: https://github.com/apache/lucene-solr/pull/1103#discussion_r360480535
 
 

 ##########
 File path: lucene/suggest/src/java/org/apache/lucene/search/spell/DirectSpellChecker.java
 ##########
 @@ -75,6 +75,8 @@
   private float thresholdFrequency = 0f;
   /** minimum length of a query word to return suggestions */
   private int minQueryLength = 4;
+  /** maximum length of a query word to return suggestions */
+  private int maxQueryLength = 0;
 
 Review comment:
   Thanks for the comments - I've put in validation and switched to using Integer.MAX_VALUE.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene-solr] andywebb1975 commented on a change in pull request #1103: LUCENE-9102 add maxQueryLength option to DirectSpellChecker

Posted by GitBox <gi...@apache.org>.
andywebb1975 commented on a change in pull request #1103: LUCENE-9102 add maxQueryLength option to DirectSpellChecker
URL: https://github.com/apache/lucene-solr/pull/1103#discussion_r360482003
 
 

 ##########
 File path: lucene/suggest/src/java/org/apache/lucene/search/spell/DirectSpellChecker.java
 ##########
 @@ -198,6 +200,19 @@ public void setMinQueryLength(int minQueryLength) {
     this.minQueryLength = minQueryLength;
   }
 
+  /** Get the maximum length of a query term to return suggestions */
+  public int getMaxQueryLength() {
+    return maxQueryLength;
+  }
+
+  /** 
+   * Set the maximum length of a query term (default: 0, i.e. no maximum)
+   * to return suggestions. 
+   */
 
 Review comment:
   I've added a second line - happy to take others' input here if there are better words to use!

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene-solr] bruno-roustant commented on a change in pull request #1103: LUCENE-9102 add maxQueryLength option to DirectSpellChecker

Posted by GitBox <gi...@apache.org>.
bruno-roustant commented on a change in pull request #1103: LUCENE-9102 add maxQueryLength option to DirectSpellChecker
URL: https://github.com/apache/lucene-solr/pull/1103#discussion_r360348691
 
 

 ##########
 File path: lucene/suggest/src/java/org/apache/lucene/search/spell/DirectSpellChecker.java
 ##########
 @@ -317,7 +332,11 @@ public void setDistance(StringDistance distance) {
       SuggestMode suggestMode, float accuracy) throws IOException {
     final CharsRefBuilder spare = new CharsRefBuilder();
     String text = term.text();
-    if (minQueryLength > 0 && text.codePointCount(0, text.length()) < minQueryLength)
+
+    int textLength = text.codePointCount(0, text.length());
+    if (minQueryLength > 0 && textLength < minQueryLength)
+      return new SuggestWord[0];
+    if (maxQueryLength > 0 && textLength > maxQueryLength)
 
 Review comment:
   Here we could group the "if" check, remove the maxQueryLength > 0 condition (with maxQueryLength initialized to Integer.MAX_VALUE), and have only one return empty array because this is the same semantic (and add brackets).

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene-solr] bruno-roustant commented on a change in pull request #1103: LUCENE-9102 add maxQueryLength option to DirectSpellChecker

Posted by GitBox <gi...@apache.org>.
bruno-roustant commented on a change in pull request #1103: LUCENE-9102 add maxQueryLength option to DirectSpellChecker
URL: https://github.com/apache/lucene-solr/pull/1103#discussion_r360348014
 
 

 ##########
 File path: lucene/suggest/src/java/org/apache/lucene/search/spell/DirectSpellChecker.java
 ##########
 @@ -75,6 +75,8 @@
   private float thresholdFrequency = 0f;
   /** minimum length of a query word to return suggestions */
   private int minQueryLength = 4;
+  /** maximum length of a query word to return suggestions */
+  private int maxQueryLength = 0;
 
 Review comment:
   I prefer to initialize maxQueryLength to Integer.MAX_VALUE, it's more intuitive, so that there is no special <= 0 or < min value.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene-solr] andywebb1975 commented on a change in pull request #1103: LUCENE-9102 add maxQueryLength option to DirectSpellChecker

Posted by GitBox <gi...@apache.org>.
andywebb1975 commented on a change in pull request #1103: LUCENE-9102 add maxQueryLength option to DirectSpellChecker
URL: https://github.com/apache/lucene-solr/pull/1103#discussion_r360481010
 
 

 ##########
 File path: lucene/suggest/src/java/org/apache/lucene/search/spell/DirectSpellChecker.java
 ##########
 @@ -317,7 +332,11 @@ public void setDistance(StringDistance distance) {
       SuggestMode suggestMode, float accuracy) throws IOException {
     final CharsRefBuilder spare = new CharsRefBuilder();
     String text = term.text();
-    if (minQueryLength > 0 && text.codePointCount(0, text.length()) < minQueryLength)
+
+    int textLength = text.codePointCount(0, text.length());
+    if (minQueryLength > 0 && textLength < minQueryLength)
+      return new SuggestWord[0];
+    if (maxQueryLength > 0 && textLength > maxQueryLength)
 
 Review comment:
   Yes to both!

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene-solr] asfgit closed pull request #1103: LUCENE-9102: add maxQueryLength option to DirectSpellChecker

Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #1103: LUCENE-9102: add maxQueryLength option to DirectSpellChecker
URL: https://github.com/apache/lucene-solr/pull/1103
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


[GitHub] [lucene-solr] bruno-roustant commented on a change in pull request #1103: LUCENE-9102: add maxQueryLength option to DirectSpellChecker

Posted by GitBox <gi...@apache.org>.
bruno-roustant commented on a change in pull request #1103: LUCENE-9102: add maxQueryLength option to DirectSpellChecker
URL: https://github.com/apache/lucene-solr/pull/1103#discussion_r360642971
 
 

 ##########
 File path: lucene/suggest/src/java/org/apache/lucene/search/spell/DirectSpellChecker.java
 ##########
 @@ -195,9 +197,27 @@ public int getMinQueryLength() {
    * metric.
    */
   public void setMinQueryLength(int minQueryLength) {
+    if (minQueryLength > this.maxQueryLength)
 
 Review comment:
   Actually I think we don't need these checks because whatever the value for minQueryLength and maxQueryLength, the logic is always the same, no surprise.
   So personally I would remove these checks, but I'm ok to keep them, your choice.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org