Elasticsearch regexp on query -
i have following query works great:
query: { multi_match: { fields: ["first_name", "last_name", "email", "sku"], query: query, type: "cross_fields", operator: "and" }
however, i'd have incoming query
rid of non-alphanumeric characters, using regex:
[^a-za-z0-9\ @\.]
is there way have elasticsearch filter incoming query
regex fields?
you can specify different analyzer search during query construction.
query: { multi_match: { fields: ["first_name", "last_name", "email", "sku"], query: query, type: "cross_fields", operator: "and", analyzer: "your-custom-analyzer" }
you have provide definition of "your-custom-analyzer" in mapping. analyzer definition can use pattern replace filter meet requirement.