You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "msfroh (via GitHub)" <gi...@apache.org> on 2026/10/12 14:19:31 UTC

[PR] Modify AutomatonQuery to take CompiledAutomaton [lucene]

msfroh opened a new pull request, #16816:
URL: https://github.com/apache/lucene/pull/16816

   
   
   ### Description
   
   This allows us to compute a RewriteMethod that handles special cases of automata.
   
   Along with that, it modifies FieldExistsQuery to support fields that do not have norms, doc values, or vectors, but have terms.
   
   This was based on a conversation that I had with @romseygeek at Community over Code, related to https://github.com/apache/lucene/pull/16801
   


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] Rewrite special case AutomatonQueries (ALL, NONE, SINGLE) [lucene]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #16816:
URL: https://github.com/apache/lucene/pull/16816#issuecomment-6457346558

   This PR has not had activity in the past 2 weeks, labeling it as stale. If the PR is waiting for review, notify the dev@lucene.apache.org list. Thank you for your contribution!


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] Add private constructor to AutomatonQuery that takes CompiledAutomaton [lucene]

Posted by "msfroh (via GitHub)" <gi...@apache.org>.
msfroh commented on PR #16816:
URL: https://github.com/apache/lucene/pull/16816#issuecomment-6146553317

   > In modern java we don't need to do it this way anymore thanks to [JEP 513](https://openjdk.org/jeps/513).
   
   Wow! I didn't know about that feature. That's really nice.


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] Add private constructor to AutomatonQuery that takes CompiledAutomaton [lucene]

Posted by "rmuir (via GitHub)" <gi...@apache.org>.
rmuir commented on code in PR #16816:
URL: https://github.com/apache/lucene/pull/16816#discussion_r4254089183


##########
lucene/core/src/java/org/apache/lucene/search/FieldExistsQuery.java:
##########
@@ -152,10 +165,19 @@ public Query rewrite(IndexSearcher indexSearcher) throws IOException {
           allReadersRewritable = false;
           break;
         }
+      } else if (fieldInfo.getIndexOptions() != IndexOptions.NONE) { // the field only indexes terms

Review Comment:
   maybe if we moved this line comment to be the first comment inside the "else if" we'd get better formatting throughout here. It works in this case, but in the other cases below it is causing confusing wrapping



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] Modify AutomatonQuery to take CompiledAutomaton [lucene]

Posted by "msfroh (via GitHub)" <gi...@apache.org>.
msfroh closed pull request #16816: Modify AutomatonQuery to take CompiledAutomaton
URL: https://github.com/apache/lucene/pull/16816


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] Add private constructor to AutomatonQuery that takes CompiledAutomaton [lucene]

Posted by "msfroh (via GitHub)" <gi...@apache.org>.
msfroh commented on PR #16816:
URL: https://github.com/apache/lucene/pull/16816#issuecomment-6129195131

   Thanks, @rmuir! I switched to adding a private constructor and delegating to that. It makes the diff a lot smaller, since we don't touch any of the `AutomatonQuery` subclass.


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] Add private constructor to AutomatonQuery that takes CompiledAutomaton [lucene]

Posted by "rmuir (via GitHub)" <gi...@apache.org>.
rmuir commented on PR #16816:
URL: https://github.com/apache/lucene/pull/16816#issuecomment-6146711021

   > Along with that, it modifies FieldExistsQuery to support fields that do not have norms, doc values, or vectors, but have terms.
   
   I tried to review the change, which overall makes sense, but this piece left me a bit confused. I guess it seems kinda trappy to enumerate entire terms dictionary just to detect if a field exists. What is the use-case?


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] Add private constructor to AutomatonQuery that takes CompiledAutomaton [lucene]

Posted by "rmuir (via GitHub)" <gi...@apache.org>.
rmuir commented on PR #16816:
URL: https://github.com/apache/lucene/pull/16816#issuecomment-6148615141

   > Just trying to maintain functional consistency with an `ALL` type automaton for the case where a field does not have norms or doc values. I think that `field:*` should be equivalent to (and rewrite to) `exists(field)`. I decided to make `exists(field)` work in all cases, but I'm okay with making `field:*` throw an exception when the field doesn't have norms or doc values. We can still avoid throwing an exception in the MatchAll/MatchNoDocsQuery special cases.
   
   OK. I agree someone can just do a leading wildcard anyway which is just as bad. 


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] Add private constructor to AutomatonQuery that takes CompiledAutomaton [lucene]

Posted by "rmuir (via GitHub)" <gi...@apache.org>.
rmuir commented on PR #16816:
URL: https://github.com/apache/lucene/pull/16816#issuecomment-6136536925

   @msfroh i'd prefer if we didn't add a constructor (even private) taking this CompiledAutomaton. In modern java we don't need to do it this way anymore thanks to [JEP 513](https://openjdk.org/jeps/513).
   
   Here is one example for this case:
   
   ```java
   public AutomatonQuery(final Term term, Automaton automaton, boolean isBinary, RewriteMethod rewriteMethod) {
     // compute local variable before super() call
     var compiled = new CompiledAutomaton(automaton, false, true, isBinary);
     super(term.field(), specialCaseRewriteMethod(compiled, rewriteMethod));
     this.term = term;
     this.automaton = automaton;
     this.automatonIsBinary = isBinary;
     this.compiled = compiled;
   
     // compiled may already reference the same Automaton instance; only count its bytes once.
     long automatonBytes = compiled.sharesAutomaton(automaton) ? 0L : automaton.ramBytesUsed();
     this.ramBytesUsed =
         BASE_RAM_BYTES + term.ramBytesUsed() + automatonBytes + compiled.ramBytesUsed();
   }
   ```
   
   I hope we can take advantage of the feature to avoid odd workarounds just like here (i know we have some elsewhere too)


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] Add private constructor to AutomatonQuery that takes CompiledAutomaton [lucene]

Posted by "msfroh (via GitHub)" <gi...@apache.org>.
msfroh commented on PR #16816:
URL: https://github.com/apache/lucene/pull/16816#issuecomment-6147615690

   > I guess it seems kinda trappy to enumerate entire terms dictionary just to detect if a field exists. What is the use-case?
   
   Just trying to maintain functional consistency with an `ALL` type automaton for the case where a field does not have norms or doc values. I think that `field:*` should be equivalent to (and rewrite to) `exists(field)`. I decided to make `exists(field)` work in all cases, but I'm okay with making `field:*` throw an exception when the field doesn't have norms or doc values. We can still avoid throwing an exception in the MatchAll/MatchNoDocsQuery special cases.


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] Modify AutomatonQuery to take CompiledAutomaton [lucene]

Posted by "rmuir (via GitHub)" <gi...@apache.org>.
rmuir commented on PR #16816:
URL: https://github.com/apache/lucene/pull/16816#issuecomment-6126512435

   Can we avoid making this public in the API? AFAIK it was made public just to be reachable by codecs. Can we address the java packaging limitations in an alternative way?


-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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