Hello is there a way to format a keyword into a phone number?
For example I have:
2221110000
But I would want something like this
222-111-0000
Hello is there a way to format a keyword into a phone number?
For example I have:
2221110000
But I would want something like this
222-111-0000
The only way I can see would be by using runtime fields and build a script that emit the right text value you want.
This worked:
StringBuilder sb = new StringBuilder();
StringBuilder temp = new StringBuilder(doc['number.keyword'].value);
while (temp.length() < 10)
temp.insert(0, "0");
char[] chars = temp.toString().toCharArray();
sb.append("(");
for (int i = 0; i < chars.length; i++) {
if (i == 3)
sb.append(") ");
else if (i == 6)
sb.append("-");
sb.append(chars[i]);
}
emit(sb.toString());
Code is coming from How do format a phone number as a String in Java? - Stack Overflow
It gives:
© 2020. All Rights Reserved - Elasticsearch
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant logo are trademarks of the Apache Software Foundation in the United States and/or other countries.