Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filter or analyzer to equate English numbers and arabic numerals

I'm running an Elasticsearch server.

I'd like a query such as fifty two meters to match a document containing 52 meters.

Is there any plugin (filter or analyzer) that converts number words to arabic numerals?

like image 917
Garrett Avatar asked Dec 10 '16 03:12

Garrett


1 Answers

Currently there is no plug-in for elasticsearch to convert words to number.

I suggest you to create a code that gets raw query as an input and outputs the transformed the query (i.e: convert words to number) for elasticsearch.

You can use this ruby gem (open-source) to convert words to number and vice versa.

NumbersInWords.in_numbers("nineteen sixty five")
1965

And to make things easier ruby intergration for elasticsearch can used to finally query the elasticsearch and get the results.

require 'elasticsearch'

client = Elasticsearch::Client.new log: true

client.transport.reload_connections!

client.cluster.health

client.search q: 'test'
like image 119
Dulguun Avatar answered Oct 22 '22 01:10

Dulguun