You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Julie Tibshirani (JIRA)" <ji...@apache.org> on 2018/05/07 17:33:00 UTC

[jira] [Comment Edited] (LUCENE-8287) ContextQuery with empty RegexCompletionQuery produces an assertion failure

    [ https://issues.apache.org/jira/browse/LUCENE-8287?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16466226#comment-16466226 ] 

Julie Tibshirani edited comment on LUCENE-8287 at 5/7/18 5:32 PM:
------------------------------------------------------------------

I uploaded a patch that throws an IllegalArgumentException if an empty term is passed to RegexCompletionQuery.

This approach certainly works, but I just wanted to note that the behavior is a bit inconsistent with a normal RegexpQuery, where an empty term is accepted, but the query produces no results.


was (Author: jtibshirani):
I uploaded a patch that throws an IllegalArgumentException if an empty term is passed to RegexCompletionQuery.

This approach certainly works, but I just wanted to note that the behavior is a bit different in a normal RegexpQuery, where an empty term is accepted, but the query produces no results.

> ContextQuery with empty RegexCompletionQuery produces an assertion failure
> --------------------------------------------------------------------------
>
>                 Key: LUCENE-8287
>                 URL: https://issues.apache.org/jira/browse/LUCENE-8287
>             Project: Lucene - Core
>          Issue Type: Bug
>            Reporter: Julie Tibshirani
>            Priority: Major
>         Attachments: LUCENE-8287-repro.patch, LUCENE-8287.patch
>
>
> When an empty RegexCompletionQuery is provided to ContextQuery, the following assertion failure occurs:
> {code:java}
> java.lang.AssertionError: input should not end with the context separator
> at org.apache.lucene.search.suggest.document.ContextQuery$ContextCompletionWeight.setInnerWeight(ContextQuery.java:296)
> at org.apache.lucene.search.suggest.document.ContextQuery$ContextCompletionWeight.setNextMatch(ContextQuery.java:275)
> at org.apache.lucene.search.suggest.document.NRTSuggester.lookup(NRTSuggester.java:221)
> at org.apache.lucene.search.suggest.document.CompletionScorer.score(CompletionScorer.java:70)
> at org.apache.lucene.search.BulkScorer.score(BulkScorer.java:39)
> at org.apache.lucene.search.suggest.document.SuggestIndexSearcher.suggest(SuggestIndexSearcher.java:78)
> at org.apache.lucene.search.suggest.document.SuggestIndexSearcher.suggest(SuggestIndexSearcher.java:58)
> at org.apache.lucene.search.suggest.document.TestContextQuery.testEmptyRegexQuery(TestContextQuery.java:193)
> {code}
> This is a bit of an edge case, but may be concerning since without assertions enabled, you can go on to access IntsRef indices that are out of bounds.
> The attached patch provides a reproduction of the issue, as the test case TestContextQuery#testEmptyRegexQuery. Note that to reproduce, Java assertions must be enabled (as in the default configuration for tests).
> The patch also provides a test case for the normal behavior of an empty RegexCompletionQuery, when it is not wrapped in ContextQuery (TestRegexCompletionQuery#testEmptyRegexQuery). In this case, there is no error, and all suggestions are returned. 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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