searching emails in tire (elastic serach) not working

205 Views Asked by At

How to index emails in tire.

i want a full model search including email. The problem is [email protected] is not working in search as it as '@' character so it splits up.

this is my query

query { terms :_all, params[:query], :minimum_match => 10} if params[:query].present?

if i used "include_in_all: false" then how i can include email in query serach or how to send both _all and email in terms query

is there any workable solution to fully index email without splitting so that it can be included in _all.

tried 'tokenizer' => 'uax_url_email'? but not working . how to set it correctly in rails

1

There are 1 best solutions below

2
On

Here's a gist of how to create an index with the _all field using the uax_url_email tokenizer.

Another solution would be to index the email field as not_analyzed.

        "email": {
            "type": "multi_field",
            "fields": {
                "email": {"type": "string", "index": "analyzed"},
                "exact": {"type": "string","index": "not_analyzed"}
            }
        }

Querying on the "email.exact" term will return the exact email value, without splitting on the "@".