[bug] Search by field which contain "@"

Hi guys,
I have a problem with search by field which contain "@" (email field).
---create a new entity---

POST http://ua1-2003-pc.gtech.local:9200/idx2/create HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Basic ZWxhc3RpYzpjaGFuZ2VtZQ==
User-Agent: Telerik Test Studio for APIs
Host: ua1-2003-pc.gtech.local:9200
Content-Length: 121
Expect: 100-continue
Connection: Keep-Alive
{
	"id": 541706163,
	"message": "messaaage",
	"email": "test@gmail.com",
	"state": "staaate",
	"count": 541706163
}

--- get response ---

HTTP/1.1 201 Created
Content-Length: 158
Content-Type: application/json; charset=UTF-8
Location: /idx2/create/AV2eb15oXF93XOTI570L
{"_index":"idx2","_type":"create","_id":"AV2eb15oXF93XOTI570L","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"created":true}

--- try to search ---

POST http://ua1-2003-pc.gtech.local:9200/idx2/_search HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Basic ZWxhc3RpYzpjaGFuZ2VtZQ==
User-Agent: Telerik Test Studio for APIs
Host: ua1-2003-pc.gtech.local:9200
Content-Length: 133
Expect: 100-continue
Connection: Keep-Alive
{
	"query": {
		"bool": {
			"filter": {
				"prefix": {
					"email": {
						"value": "test"
					}
				}
			}
		}
	}
}

--- get response ---

HTTP/1.1 200 OK
Content-Length: 329
Content-Type: application/json; charset=UTF-8
{"took":2,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max_score":0.0,"hits":[{"_index":"idx2","_type":"create","_id":"AV2eb15oXF93XOTI570L","_score":0.0,"_source":{
	"id": 541706163,
	"message": "messaaage",
	"email": "test@gmail.com",
	"state": "staaate",
	"count": 541706163
}}]}}

but in case when I try use "value": "test@gmail.com"
or "value": "test@" I get hits.total 0

{
  "name" : "UA1-2003-PC",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "1LP3cU92ScaaBom-2DD-MQ",
  "version" : {
    "number" : "5.5.0",
    "build_hash" : "260387d",
    "build_date" : "2017-06-30T23:16:05.735Z",
    "build_snapshot" : false,
    "lucene_version" : "6.6.0"
  },
  "tagline" : "You Know, for Search"
}

It's the way analyzers are working. You need to understand how analysis is working.
A prefix query is not analyzed. So your query does not match what you have in the inverted index.

sorry, I'm not sure that understood

if it is typical work of analyzer, so how I can set a prefix or term for emails?

This is working well:

DELETE test
PUT test
{
  "mappings": {
    "doc": {
      "properties": {
        "email": {
          "type": "keyword"
        }
      }
    }
  }
}
PUT test/doc/1
{
	"email": "test@gmail.com"
}
GET test/_search
{
	"query": {
		"bool": {
			"filter": {
				"prefix": {
					"email": {
						"value": "test@"
					}
				}
			}
		}
	}
}

thanks, it helps

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.