apache / apache/lucene

Non-tokenized fields become tokenized when a document is deleted and added back [LUCENE-3854]

Open
#4,927 11 comments 0 reactions 0 assignees View on GitHub
affects-version:4.0-ALPHA legacy-jira-priority:Major module:core/index type:bug
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

https://github.com/bimargulies/lucene-4-update-case is a JUnit test case that seems to show a problem with the current trunk. It creates a document with a Field typed as StringField.TYPE_STORED and a value with a "-" in it. A TermQuery can find the value, initially, since the field is not tokenized.

Then, the case reads the Document back out through a reader. In the copy of the Document that gets read out, the Field now has the tokenized bit turned on.

Next, the case deletes and adds the Document. The 'tokenized' bit is respected, so now the field gets tokenized, and the result is that the query on the term with the - in it no longer works.

So I think that the defect here is in the code that reconstructs the Document when read from the index, and which turns on the tokenized bit.

I have an ICLA on file so you can take this code from github, but if you prefer I can also attach it here.

---
Migrated from [LUCENE-3854](https://issues.apache.org/jira/browse/LUCENE-3854) by Benson Margulies (@bimargulies-google), updated Jun 12 2012

Contributor guide

Open the contributing guide

Research direction

Start by running the JUnit test case at https://github.com/bimargulies/lucene-4-update-case and reproduce the failure around StringField.TYPE_STORED, Document reading, deletion, and re-addition. Trace the code that reconstructs a Document from the index; done means the field remains non-tokenized and the TermQuery still finds the value containing "-" after the document is re-added.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
search
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.