[
https://issues.apache.org/jira/browse/LUCENE-7027?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15145917#comment-15145917
]
Michael McCandless commented on LUCENE-7027:
--------------------------------------------
bq. The cause is known and the issue reported here is just some broken usage of
NumericTokenStream in user code that looks totally broken anyways,
Hmm, I don't think this usage is broken? The public {{TokenStream}} API has a
contract and the public {{NumericTokenStream}} fails to implement it properly ;)
Or maybe you are saying one can never call {{captureState}} after calling
{{end}}? But then how does one hang onto the "final" offset and posInc? And
if so, I guess we should fix {{MockTokenizer}} to enforce this? Yet,
{{CachingTokenFilter}} is doing exactly this, so maybe the bug is there?
Our analysis APIs are way too complex! They are like a 747 cockpit. We can't
even agree on which buttons you are allowed to press, when.
bq. I have no idea why Elasticsearch uses the class at all!
Well, Elasticsearch's simple query parser is just trying to create the right
"equals" query from the incoming text, for a numeric field. Here's the query:
{noformat}
{"simple_query_string":{"query":"123","fields":["foo","bar"]}}
{noformat}
It does this today by using the appropriate tokenizer given the field type, and
for numerics that's supposed to be {{NumericTokenStream}}. But then we hit
this bug, seen in ES originally at
https://github.com/elastic/elasticsearch/issues/16577
Yes, ES can work around this bug if we leave Lucene buggy, which is exactly
what that PR is doing, by "special casing" numerics by explicitly creating a
{{TermQuery}} using the full precision numeric term, instead of trusting its
type-specific tokenizer to work correctly.
bq. Because of the corner case and possible performance corner cases, I'd tend
to close this as won't fix.
Hmm I think correctness trumps performance?
> NumericTokenStream doesn't implement end() correctly
> ----------------------------------------------------
>
> Key: LUCENE-7027
> URL: https://issues.apache.org/jira/browse/LUCENE-7027
> Project: Lucene - Core
> Issue Type: Bug
> Affects Versions: 5.5, master, 6.0
> Reporter: Michael McCandless
> Assignee: Uwe Schindler
> Attachments: LUCENE-7027-master.patch
>
>
> This small test:
> {noformat}
> public void testCloneFullPrecisionToken() throws Exception {
> FieldType fieldType = new FieldType(IntField.TYPE_NOT_STORED);
> fieldType.setNumericPrecisionStep(Integer.MAX_VALUE);
> Field field = new IntField("field", 17, fieldType);
> TokenStream tokenStream = new CachingTokenFilter(field.tokenStream(null,
> null));
> assertTrue(tokenStream.incrementToken());
> }
> {noformat}
> hits this unexpected exception:
> {noformat}
> There was 1 failure:
> 1)
> testCloneFullPrecisionToken(org.apache.lucene.analysis.TestNumericTokenStream)
> java.lang.IllegalArgumentException: Illegal shift value, must be 0..31; got
> shift=2147483647
> at
> __randomizedtesting.SeedInfo.seed([2E1E93EF810CB5F7:EF1304A849574BC7]:0)
> at
> org.apache.lucene.util.NumericUtils.intToPrefixCodedBytes(NumericUtils.java:175)
> at
> org.apache.lucene.util.NumericUtils.intToPrefixCoded(NumericUtils.java:133)
> at
> org.apache.lucene.analysis.NumericTokenStream$NumericTermAttributeImpl.getBytesRef(NumericTokenStream.java:165)
> at
> org.apache.lucene.analysis.NumericTokenStream$NumericTermAttributeImpl.clone(NumericTokenStream.java:217)
> at
> org.apache.lucene.analysis.NumericTokenStream$NumericTermAttributeImpl.clone(NumericTokenStream.java:148)
> at
> org.apache.lucene.util.AttributeSource$State.clone(AttributeSource.java:55)
> at
> org.apache.lucene.util.AttributeSource.captureState(AttributeSource.java:288)
> at
> org.apache.lucene.analysis.CachingTokenFilter.fillCache(CachingTokenFilter.java:96)
> at
> org.apache.lucene.analysis.CachingTokenFilter.incrementToken(CachingTokenFilter.java:70)
> at
> org.apache.lucene.analysis.TestNumericTokenStream.testCloneFullPrecisionToken(TestNumericTokenStream.java:138)
> {noformat}
> because {{CachingTokenFilter}} expects that it can {{captureState}} after
> calling {{end}} but {{NumericTokenStream}} gets angry about this.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]