Hi Rajnish It is not advisable to index values with two data types in a field. Features like phrase query, sorting may break in those indexes.
related previous discussion : http://www.gossamer-threads.com/lists/lucene/java-user/289159?do=post_view_flat#289159 - Kumaran R On Fri, Nov 4, 2016 at 8:30 AM, Rajnish kamboj <rajnishk7.i...@gmail.com> wrote: > Hi > > Is it advisable to store and index values of different datatype under same > field as follows > > Field field = new LongField("*region*", 10L, Field.Store.YES); > doc.add(field); > Field field1 = new StringField("*region*", "NORTH", Field.Store.YES); > doc.add(field1); > > Our field "region" can have numeric and string data types. > > Our query can have two patterns as under: > #1 region="NORTH" > #2 region in range 5 TO 20 > > Though we are able to index and retrieve desired results but, > > *We could not find Lucene (5.3.1) documentation around this behavior.* > Please comment on, > 1. If we can go with this behavior and what would be the performance > implication of indexing and querying different datatype under same field? > 2. How the two are stored internally (i.e. different datatype under same > field)? > 2. If we upgrade to new Lucene version 5.4 or to major 6.0.0, then will the > above behavior work or it may break? > > > Regards > Rajnish >