# Ignoring punctuation for sorting

**URL:** <https://discuss.elastic.co/t/ignoring-punctuation-for-sorting/193520>\
**Category:** Elasticsearch\
**Created:** [August 2, 2019, 11:45am UTC](https://discuss.elastic.co/t/ignoring-punctuation-for-sorting/193520 "2019-08-02T11:45:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![spunto](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spunto/32/51520_2.png) [@spunto](https://discuss.elastic.co/u/spunto)\
**Post date:** [August 2, 2019, 11:45am UTC](https://discuss.elastic.co/t/ignoring-punctuation-for-sorting/193520/1 "2019-08-02T11:45:51Z")

</div>

Hello,

When sorting on the field "Title", my client is unhappy that records with a title in quotes, or with leading spaces, will be at the top. I've thought of a few ways around this, but they all have problems. One of the main issues is that this data takes over twenty-four hours to index fully, from scratch, so re-indexing is not a feasible option.

1. I could use a sorting strategy which ignores the punctuation — but I'm not sure how to do that at query time. I thought of using a script sort with a regex, but as far as I can make out, that isn't possible — we can sort on whether or not a term matches the pattern, but we can't sort on a term as it has been altered by a regex search-and-replace.

2. I could create a new field, based on the value of the Title field — call it SortTitle — just for sorting. Again, I don't know how to go about this either. I've read so much documentation I feel I know less than when I began. Again, it seems regex can be used as a conditional, but not for calculating the value of a new field based on the value of an old one.

Thanks,  
Ben

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 30, 2019, 11:45am UTC](https://discuss.elastic.co/t/ignoring-punctuation-for-sorting/193520/2 "2019-08-30T11:45:52Z")

</div>

Closed on August 30, 2019, 11:45am UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
