I am running ES 5.3.3.
I've got a document field name
, value: L-tryp-something
which I am trying to find.
This query gives no result:
"wildcard" : { "name" : { "wildcard" : "L-tryp*", "boost" : 2.0 } }
However this works fine:
"query_string" : {
"default_field": "name",
"query": "L-Tryp*",
"boost" : 2.0
}
Any idea why is that?
Here is full curl command set to create index, index a document, then execute 2 searches:
curl -XPUT "http://localhost:9200/test" -d '{"mappings": {
"substance": {
"properties": {
"name": {
"type": "text",
"analyzer":"lowercase_keyword_analyzer",
"fields": {
"nGram": {
"type": "text",
"analyzer": "lowercase_ngram_keyword_analyzer"
}
}
}
}
}
}, "settings": {
"index": {
"analysis": {
"filter": {
"ngram": {
"type": "nGram",
"min_gram": "1",
"max_gram": "10"
}
},
"analyzer": {
"lowercase_ngram_keyword_analyzer": {
"filter": [
"lowercase",
"ngram"
],
"tokenizer": "keyword"
},
"lowercase_keyword_analyzer": {
"filter": [
"lowercase"
],
"tokenizer": "keyword"
}
}
}
}
}}'
curl -XPUT "localhost:9200/test/substance/2320" -H 'Content-Type: application/json' -d'
{
"name" : "L-tryp-something"
}
'
curl -XPOST "localhost:9200/test/_search" -d'
{
"query": {
"wildcard" : { "name" : { "wildcard" : "L-tryp*", "boost" : 2.0 } }
}
}
'
curl -XPOST "localhost:9200/test/_search" -d'
{
"query": {
"query_string" : {
"default_field": "name",
"query": "L-Tryp*",
"boost" : 2.0
}
}
}'