Skip to content

Instantly share code, notes, and snippets.

@astefan
Created September 21, 2015 07:10
Show Gist options
  • Save astefan/a52fa4989bf5298102d1 to your computer and use it in GitHub Desktop.
Save astefan/a52fa4989bf5298102d1 to your computer and use it in GitHub Desktop.
Testing special chars and query_string
DELETE /test
PUT test
{
"settings": {
"analysis": {
"analyzer": {
"my_ngram_analyzer": {
"tokenizer": "keyword",
"filter": [
"substring"
]
}
},
"filter": {
"substring": {
"type": "nGram",
"min_gram": 1,
"max_gram": 50
}
}
}
},
"mappings": {
"test": {
"properties": {
"Path": {
"type": "string",
"index_analyzer": "my_ngram_analyzer",
"search_analyzer": "keyword"
}
}
}
}
}
POST /test/test/_bulk
{"index":{}}
{"Path":"C:\\temp\\ab-cd\\abc.doc@ddd"}
{"index":{}}
{"Path":"C:\\temp\\ab-cd\\abc.doc"}
{"index":{}}
{"Path":"C:temp\\ab-cd\\bc.docddd"}
{"index":{}}
{"Path":"C:temp\\ab-cd\\bc.doc"}
GET /test/test/_search
{
"query": {
"query_string": {
"default_field": "Path",
"query": "ab\\-cd"
}
}
}
GET /test/test/_search
{
"query": {
"query_string": {
"default_field": "Path",
"query": "cd\\\\abc"
}
}
}
GET /test/test/_search
{
"query": {
"query_string": {
"default_field": "Path",
"query": "C\\:\\\\temp"
}
}
}
GET /test/test/_search
{
"query": {
"query_string": {
"default_field": "Path",
"query": "C\\:temp"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment