How to know if search query contains numbers

I posted a question earlier, but nobody seems to be able to answer it so I am trying a gain with a different explanation.

Is there a way to know if a search query contains numbers (or not words)?

Take the following example;

{
  "query": {
    "match": {
      "title": "vacation 2017"
    }
  }
}

Is there some way to set up either the query or the mappings/settings in the index, so that when people search for "vacation 2017" the search engine will suggest documents that contains both terms OR documents that contains ONLY the word and not the year? The year is in this case only relevant in combination with the word. It has no meaning on its own.

hey,

you could index your data in a field which drops all number, so you only search in text. queries have to hit in this field and by using a bool query with a should clause you could score up those documents which have 'vacation 2017' as well.

hope that makes a little bit sense.

--Alex

I'm not 100% sure what you mean. You mean that I have to write my own code that removes numbers before I index the document?

I was hoping that I could create an analyzer that would do this for me. The same way that you can create analyzers with filters that "removes" stopwords.

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