Skip to content

Instantly share code, notes, and snippets.

@chrisberkhout
Created November 28, 2011 10:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisberkhout/76a009affd2df4b91ccd to your computer and use it in GitHub Desktop.
Save chrisberkhout/76a009affd2df4b91ccd to your computer and use it in GitHub Desktop.
problem with english analyzer in ES 0.18.4?
# Using the english analyzer...
curl -X DELETE "http://localhost:9200/test"
curl -X POST "http://localhost:9200/test" -d '{
"settings": {
"number_of_shards": 1,
"analysis": {
"analyzer": {
"default": {
"type": "english"
}
}
}
}
}'
curl -X POST "http://localhost:9200/test/keyword/1" -d '{"name_en":"PICKONLYME"}'
curl -X POST "http://localhost:9200/test/_refresh"
# This query returns no hits
curl -X GET "http://localhost:9200/test/_search?pretty=true" -d '{
"query": {
"bool": {
"must": [{
"text": {
"_all": {
"query": "PICKONLYME",
"operator": "and"
}
}
}]
}
},
"size": 15
}'
# And a test analysis of "PICKONLYME" returns
{
"tokens": [
{
"token": "pickonlym",
"start_offset": 0,
"end_offset": 10,
"type": "<ALPHANUM>",
"position": 1
}
]
}
# Without analysis...
curl -X DELETE "http://localhost:9200/test"
curl -X POST "http://localhost:9200/test" -d '{"settings":{"number_of_shards":1}}'
curl -X POST "http://localhost:9200/test/keyword/1" -d '{"name_en":"PICKONLYME"}'
curl -X POST "http://localhost:9200/test/_refresh"
# It does work.
curl -X GET "http://localhost:9200/test/_search?pretty=true" -d '{
"query": {
"bool": {
"must": [{
"text": {
"_all": {
"query": "PICKONLYME",
"operator": "and"
}
}
}]
}
},
"size": 15
}'
# With the analysis on, but indexing a word that's pre-stemmed (although not downcased)...
curl -X DELETE "http://localhost:9200/test"
curl -X POST "http://localhost:9200/test" -d '{
"settings": {
"number_of_shards": 1,
"analysis": {
"analyzer": {
"default": {
"type": "english"
}
}
}
}
}'
curl -X POST "http://localhost:9200/test/keyword/1" -d '{"name_en":"PICKONLYM"}'
curl -X POST "http://localhost:9200/test/_refresh"
# It does work, for both stemmed and unstemmed queries...
curl -X GET "http://localhost:9200/test/_search?pretty=true" -d '{
"query": {
"bool": {
"must": [{
"text": {
"_all": {
"query": "PICKONLYM",
"operator": "and"
}
}
}]
}
},
"size": 15
}'
curl -X GET "http://localhost:9200/test/_search?pretty=true" -d '{
"query": {
"bool": {
"must": [{
"text": {
"_all": {
"query": "PICKONLYME",
"operator": "and"
}
}
}]
}
},
"size": 15
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment