blob: a6ea0aa2057fe1d8a4117f614a2e3df144430cd6 [file] [log] [blame]
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexNumberAsString.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexNumberAsString.java
new file mode 100644
index 0000000..0f19729
--- /dev/null
+++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexNumberAsString.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.index;
+
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.apache.lucene.document.TextField;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.util.IOUtils;
+import org.apache.lucene.util.LuceneTestCase;
+
+public class TestIndexNumberAsString extends LuceneTestCase {
+
+ private class NumberField extends Field {
+ public NumberField(String name, long value) {
+ super(name, TextField.TYPE_STORED);
+ fieldsData = Long.valueOf(value);
+ }
+ }
+
+ // LUCENE-8108
+ public void testIndexNumberAsString() throws Exception {
+ Directory dir = newDirectory();
+ RandomIndexWriter w = new RandomIndexWriter(random(), dir);
+ Document doc = new Document();
+ doc.add(new NumberField("number", 17));
+ w.addDocument(doc);
+ IndexReader reader = w.getReader();
+ IndexSearcher s = newSearcher(reader);
+ assertEquals(0, s.count(new TermQuery(new Term("number", "17"))));
+ IOUtils.close(w, dir);
+ }
+}