Cannot search on the field with email format (contains '@' sign)


(Zhen Wu) #1
curl -XPOST 'http://localhost:9200/twitter/tweet' -d '{ "user" : "user1", "mail" : "user1@domain1.com" }

'

curl -XGET 'http://localhost:9200/twitter/tweet/_search' -d '{
"from" : 0, "size" : 10,
"query" : {
"term" : { "mail" : "user1@domain1.com" }
}
}
'

{"took":0,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}

--


(David Pilato) #2

Change your mapping for this field as you are using the default analyzer which split your email address in many tokens.
Or use a match Query instead of Term Query. Term is not analyzed. Match is.

HTH

David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 31 oct. 2012 à 10:48, Zhen Wu wuzhen0808@gmail.com a écrit :

curl -XPOST 'http://localhost:9200/twitter/tweet' -d '{ "user" : "user1", "mail" : "user1@domain1.com" }

'

curl -XGET 'http://localhost:9200/twitter/tweet/_search' -d '{
"from" : 0, "size" : 10,
"query" : {
"term" : { "mail" : "user1@domain1.com" }
}
}
'

{"took":0,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}

--

--


(Mohit Chawla) #3

You can try to either make the mail field to be not analyzed at all,
or perhaps use the uax_url_email tokenizer
http://www.elasticsearch.org/guide/reference/index-modules/analysis/uaxurlemail-tokenizer.html

On Wed, Oct 31, 2012 at 3:18 PM, Zhen Wu wuzhen0808@gmail.com wrote:

curl -XPOST 'http://localhost:9200/twitter/tweet' -d '{ "user" : "user1", "mail" : "user1@domain1.com" }

'

curl -XGET 'http://localhost:9200/twitter/tweet/_search' -d '{
"from" : 0, "size" : 10,
"query" : {
"term" : { "mail" : "user1@domain1.com" }
}
}
'

{"took":0,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}

--

--


(Zhen Wu) #4

Does it possible to make all the field not analyzed without declaration for
each one?
Such as in the index level to do this setting.

--


(Igor Motov) #5

Yes, you can define an analyzer with name "default" and type "keyword", or
use dynamic templates (preferable).

On Wednesday, October 31, 2012 11:13:34 AM UTC-4, Zhen Wu wrote:

Does it possible to make all the field not analyzed without declaration
for each one?
Such as in the index level to do this setting.

--


(system) #6