New to ES so forgive if answer's obvious. I have a domain object 'widget'
with numeric field 'code'. Can I construct a DSL query to return all
widgets whose 'code' value contains a given sequence of digits (think
autocomplete use case)? For example input '13' would match widgets with
codes: 13, 1013, 40131.
You could use a String type with a ngram analyzer. Wildcard and prefix queries are slower and I would not recommend them especially for an autocomplete feature which has to be fast!
Also, you could look at the suggest API. Unsure if it will answer to your use case though.
You can analyze _id field but I would prefer using another field than _id which is more a technical field to me than a business field.
HTH
David
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
New to ES so forgive if answer's obvious. I have a domain object 'widget' with numeric field 'code'. Can I construct a DSL query to return all widgets whose 'code' value contains a given sequence of digits (think autocomplete use case)? For example input '13' would match widgets with codes: 13, 1013, 40131.
I tried using a wildcard query (with val = "13*") but looks like that type of query does not work on numeric fields. Also tried regexp filter without success.
Do I need to map 'code' as a string field and then use regexp filter? is the answer different if the field is instead '_id'?
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.