I understand that numeric fields are not analyzed at index time. What I was hoping to do was to use a custom analyzer at query time, always, on a numeric phone number field to strip out all non-digit characters using a char_filter.
I can, in fact, do this by specifying the analyzer in my query, and it works as expected: "123-456-7890" matches 1234567890. However, I don't want to have to ensure that's done everywhere anyone queries the field. Additionally, that doesn't help me when I do a multi_match query, for example.
Hi Justin,
Numeric fields are typically reserved for representing quantities that are optimised for range queries (money, byte sizes etc).
A telephone number is a number but as a form of identifier is perhaps best indexed as a keyword field - I doubt you'll ever need to do range queries on these numbers. Keyword fields can have a normalizer to treat them.
Thanks, you're probably right about the type. I actually did play around with making it a keyword, and it did work as desired on ingest. But, it's the query behavior that's actually my primary concern here, and keywords don't allow you to specify a search_analyzer, either.
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.