[If you really need the original value of the field then]
Keep the original in a separate Lucene field, e.g. "originalAge".
P.S. It seems you can control the query parser to some extent by overriding getFieldQuery. That way it should be possible to delegate text queries to the text field, while keeping numeric queries to the integer field.
Scala sample:
val qp = new org.apache.lucene.queryparser.classic.QueryParser (Version.LUCENE_43, "age", ANALYZER_RUS) {
override def getFieldQuery (field: String, queryText: String, quoted: Boolean): org.apache.lucene.search.Query = {
println (s"getFieldQuery ($field, $queryText, $quoted)")
if (field == "age") {
if (queryText.matches ("^age(\\>|\\<)\\d+$")) super.getFieldQuery (field, queryText, quoted)
else super.getFieldQuery ("originalAge", queryText, quoted)
} else super.getFieldQuery (field, queryText, quoted)
}
}
println (qp.parse ("undefined")) // originalAge:undefined
println (qp.parse ("age>3")) // age:age age:3
You might also check the flexible query parser.