0

I've problem with parsing pipe "|" character in elasticsearch. When record have any special characters no result data. Below my query

{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "username": "john|doe@group.net"
          }
        }
      ],
      "must_not": [],
      "should": []
    }
  }, 

I tried use "tokenizer":"uax_url_email", but not working

M. Badovsky
  • 99
  • 3
  • 10
  • Can you provide an example document which should match the exact term( `john|doe@group.net` )? – avr Apr 22 '17 at 18:17
  • I've database table which contain usernames like john|doe@group.net, and i need select this using elasticsearh via above query. thats all – M. Badovsky Apr 22 '17 at 19:00
  • if you are using ES 5.x and default mapping for field `username` then replace this line `"username": "john|doe@group.net"` with `"username.keyword": "john|doe@group.net"` and try it should work. – avr Apr 22 '17 at 19:35
  • im using ES 2.4 ;/ – M. Badovsky Apr 22 '17 at 19:37
  • What is the mapping of field `username`?if it is not_analyzed field then is it possible to make it `not_analyzed` field? – avr Apr 22 '17 at 19:40
  • There is another way to have both `analyzed` and `not_analyzed` versions of a field using [multi fields concept](https://www.elastic.co/guide/en/elasticsearch/reference/2.4/multi-fields.html) – avr Apr 22 '17 at 19:49
  • It tourned out that, needed put "type":"phrase", now its okey. thanks – M. Badovsky Apr 23 '17 at 15:44

1 Answers1

1

try with query_string ,Its working .I have tested in my system with default standard analyzer Try to Use query_string . Its very powerful in partial search in ES ,check my answer link :-

:-

{ 

  "query": {
    "query_string": {
       "fields" : ["username"] ,
      "query": "john|doe@group.net"
    }
  }
}
Community
  • 1
  • 1
Vijay
  • 4,694
  • 1
  • 30
  • 38