Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Is there an actual advantage to using a numeric field over text beyond rejecting alpha characters?

Rob Horan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 5, 2019

Not a sarcastic question, I was asked this question by a client - the client is unhappy with how their data is presented (with commas, leading zeros removed) and the lack of contains search options.

2 answers

2 accepted

0 votes
Answer accepted
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 6, 2019

Numeric fields sort correctly as well (a list of 1, 4, 11 will sort in that order if it is a number, but 1, 11, 4 if it is text)

I don't think there's anything you can do about the leading 0s, but in look and feel, you can tell it not to render thousand/million/billion separators.

However, from the question, it's clear that your people should be using string fields, as they're expecting the data to behave as a string.  I'd swap to string fields and then tell them not to enter them incorrectly (or possibly validate)

Craig Castle-Mead
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 6, 2019

While I don’t know the full ins and outs of lucene performance between string and numeric fields, I feel like there’s a chance that a numeric field is more efficient to store/search a value than a string field with numbers in it (anyone able to confirm or deny)?

on top of that (and the answers above) though, from a functional point of view, if you may want to do range based queries on the values, a numeric will be better.

 

CCM

Like Nic Brough -Adaptavist- likes this
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 6, 2019

It sounds like your instinct is that numeric fields are computationally faster than text.  You are right.  A numeric field is faster than a text field for almost all operations.

But a little bit of performance is nothing to worry about when you're looking at a field, you should go with what gets your people the answers they want.  I would much rather get "right answer in 10 seconds" than "possibly a right answer, but we're not sure, in 8 seconds"

0 votes
Answer accepted
Ismael Jimoh
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 6, 2019

Hi @Rob Horan 

No there is no advantage past that. If however you are doing any fancy scripting though then I would suggest using the number field because your text field is usually converted to String rather than a number and you then need to convert again to number, hoping that the entry is valid.

Cheers.

Rob Horan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 18, 2019

Thanks!

Suggest an answer

Log in or Sign up to answer