Created
June 22, 2016 02:59
-
-
Save adamcrown/a600fc587c2c4abd4b67b2812e6e8f7d to your computer and use it in GitHub Desktop.
Elasticsearch edgengram fields in _all issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# elasticsearch: Version: 2.3.3, Build: 218bdf1/2016-05-17T15:40:04Z, JVM: 1.8.0_92 | |
# Arch Linux | |
# Kernel version 4.4.3-1-custom | |
# Setup a basic index using an edgengram filter | |
curl -XPUT "http://localhost:9200/test_index?pretty=true" -d' | |
{ | |
"settings": { | |
"analysis": { | |
"filter": { | |
"edge_ngram_filter": { | |
"type": "edge_ngram", | |
"min_gram": 2, | |
"max_gram": 20 | |
} | |
}, | |
"analyzer": { | |
"edge_ngram_analyzer": { | |
"type": "custom", | |
"tokenizer": "standard", | |
"filter": [ | |
"lowercase", | |
"edge_ngram_filter" | |
] | |
} | |
} | |
} | |
}, | |
"mappings": { | |
"doc": { | |
"properties": { | |
"text_field": { | |
"type": "string", | |
"analyzer": "edge_ngram_analyzer", | |
"search_analyzer": "standard" | |
} | |
} | |
} | |
} | |
}' | |
# Example document | |
curl -XPUT "http://localhost:9200/test_index/doc/1?pretty=true" -d' | |
{ | |
"text_field": "Hello, World!" | |
}' | |
# _all ngram search doesn't work. It retuns an empty result. | |
curl -XPOST "http://localhost:9200/test_index/_search?pretty=true" -d' | |
{ | |
"query": { | |
"match": { | |
"_all": "hell" | |
} | |
} | |
}' | |
# _all whole word search works though | |
curl -XPOST "http://localhost:9200/test_index/_search?pretty=true" -d' | |
{ | |
"query": { | |
"match": { | |
"_all": "hello" | |
} | |
} | |
}' | |
# And an ngram search on the specific field works | |
curl -XPOST "http://localhost:9200/test_index/_search?pretty=true" -d' | |
{ | |
"query": { | |
"match": { | |
"text_field": "hell" | |
} | |
} | |
}' | |
# The term vector looks fine too | |
curl -XGET "http://localhost:9200/test_index/doc/1/_termvector?fields=text_field&pretty=true" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment