-
-
Save chrisberkhout/76a009affd2df4b91ccd to your computer and use it in GitHub Desktop.
problem with english analyzer in ES 0.18.4?
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
# 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