# Autocomplete with range

**URL:** <https://discuss.elastic.co/t/autocomplete-with-range/298644>\
**Category:** Elasticsearch\
**Created:** [March 2, 2022, 3:50pm UTC](https://discuss.elastic.co/t/autocomplete-with-range/298644 "2022-03-02T15:50:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![earlyriser01](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/earlyriser01/32/102510_2.png) [@earlyriser01](https://discuss.elastic.co/u/earlyriser01)\
**Post date:** [March 2, 2022, 3:50pm UTC](https://discuss.elastic.co/t/autocomplete-with-range/298644/1 "2022-03-02T15:50:08Z")

</div>

Hi all!

I want to use my custom analyzer (autocomplete -- below) on a number field that I have indexed as shown below. I am using Ruby on Rails Elasticsearch version.

```auto
  settings index: {
     analysis: {
       filter: {
         autocomplete: {
           type: :edge_ngram,
           min_gram: 1,
           max_gram: 10, 
         }   
       },  
       analyzer: {
         autocomplete: {
           type: :custom,
           tokenizer: :standard,
           filter: %i[lowercase autocomplete]
         }   
       }   
     }   
  } 
do
    mappings dynamic: false do
      indexes :model, type: :text do
        indexes :model, type: :text, analyzer: :autocomplete
        indexes :model, type: :text, search_analyzer: :standard
      end 

       indexes :mpg, type: :text, analyzer: :english
   end
end

```

Now what I want to do is as the user types in the range of MPG they want in the search bar (have 2 fields -- so like 10 - 20 MPG), I want the autocomplete to be returning numbers automatically like my model field (i.e. 2 digits i.e. 7, 79, 80, 81 etc). However, I don't know if I can do this 3 analyzers on my MPG field? And if so, I don't know if a range can be specified on a field with a custom analyzer using edge\_ngrams? Any direction would be great.

---

<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:** [March 30, 2022, 3:50pm UTC](https://discuss.elastic.co/t/autocomplete-with-range/298644/2 "2022-03-30T15:50:59Z")

</div>

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