Need help with special character search

I have difficulties searching the special characters from my documents.

One of the attribute of the document - "phrase" - contains special characters.

Its value is -> "The 2 QUICK Brown-Foxes jumped over the lazy dog's bone #&$$$$$."

I am not able to search "#&$$$$$"

Can someone please help in searching such special characters.

I have following mapping ->

{
	"properties": {
		"student": {
			"properties": {
				"id": {
					"type": "long"
				},
				"name": {
					"type": "text"
				},
				"email": {
					"type": "text"
				},
				"gender": {
					"type": "text"
				},
				"ip_address": {
					"type": "text"
				},
				"date_of_birth": {
					"type": "date"
				},
				"company": {
					"type": "text"
				},
				"position": {
					"type": "text"
				},
				"experience": {
					"type": "long"
				},
				"country": {
					"type": "text"
				},
				"phrase": {
					"type": "text"
				},
				"salary": {
					"type": "long"
				}
			}
		}
	}
}

My query is ->

{
  "query": {
    "wildcard": {
      "phrase": {
        "value": "*#&$$$$$.*"
      }
    }
  }
}

Hi!!

when you don't define the analyzer the 'standard' will be used. It will remove the special characters, run this:

GET /_analyze
{
  "analyzer": "standard",
  "text": ["The 2 QUICK Brown-Foxes jumped over the lazy dog's bone #&$$$$$."]
}

Another option is to use the "whitespace" analyzer that will be able to keep the special character.

GET /_analyze
{
  "analyzer": "whitespace",
  "text": ["The 2 QUICK Brown-Foxes jumped over the lazy dog's bone #&$$$$$."]
}

So you need to make this change:

    "properties": {
      "phrase": {
        "type": "text",
        "analyzer": "whitespace"
      },

I have made changes as suggested by you still the query I have posted doesn't return any result. Can you please let me know how can I search the part i.e. "#&$$$$$."

My example:

PUT teste
{
  "mappings": {
    "properties": {
      "phrase": {
        "type": "text",
        "analyzer": "whitespace"
      }
    }
  }
}

POST teste/_doc
{"phrase":"The 2 QUICK Brown-Foxes jumped over the lazy dog's bone #&$$$$$."}


GET teste/_search
{
  "query": {
    "wildcard": {
      "phrase": {
        "value": "*#&$$$$$.*"
      }
    }
  }
}

I have following documents populated using _bulk ->

{ "index" : { "_index" : "student", "_id" : "1" } }
{"id":1,"name":"Huntlee Dargavel","email":"hdargavel0@japanpost.jp","gender":"male","ip_address":"58.11.89.193","date_of_birth":"11/09/1990","company":"Talane","position":"Research Associate","experience":7,"country":"China","phrase":"Multi-channelled coherent leverage #$$$$$$$$$$","salary":180025}

{ "index" : { "_index" : "student", "_id" : "2" } }
{"id":2,"name":"Othilia Cathel","email":"ocathel1@senate.gov","gender":"female","ip_address":"3.164.153.228","date_of_birth":"22/07/1987","company":"Edgepulse","position":"Structural Engineer","experience":11,"country":"China","phrase":"Grass-rootsheuristichelp-desk#&$$$$$$$$$$","salary":193530}

{ "index" : { "_index" : "student", "_id" : "3" } }
{"id":3,"name":"Winston Waren","email":"wwaren2@4shared.com","gender":"male","ip_address":"202.37.210.94","date_of_birth":"10/11/1985","company":"Yozio","position":"Human Resources Manager","experience":12,"country":"China","phrase":"Versatile object-oriented emulation #$$$$$$$$$$","salary":50616}

{ "index" : { "_index" : "student", "_id" : "4" } }
{"id" : 4,"name" : "Alan Thomas","email" : "athomas2@example.com","gender" : "male","ip_address" : "200.47.210.95","date_of_birth" : "11/12/1985","company" : "Yamaha","position" : "Resources Manager","experience" : 12,"country" : "China","phrase" : "The 2 QUICK Brown-Foxes jumped over the lazy dog's bone #&$$$$$.","salary" : 300000}

After I upload these documents, my query is failing to return.

You add analyzer in field phrase?
I will test with your data.

I had successful with your data and you?

First of all, thank you very much for your help. I am not successful yet. I am thinking probably updating the version of ES may help.

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