Skip to content

Instantly share code, notes, and snippets.

@sheroy
Created April 10, 2012 23:03
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 sheroy/2355404 to your computer and use it in GitHub Desktop.
Save sheroy/2355404 to your computer and use it in GitHub Desktop.
Elastic Search filtering with the snowball Analyzer
1. Configure and create index. The index is created with a snowball analyzer
curl -XPUT http://localhost:9200/page_index/ -d "
index:
analysis:
analyzer:
default:
tokenizer: uax_url_email
type: snowball"
2) The mapping for the page_index is
Mapping
{
"page_index" : {
"pages" : {
"properties" : {
"name" : {
"type" : "string"
},
"number" : {
"type" : "long"
}
}
}
}
}
3) A search query for the word "test" and applying a filter on a long field yields the expected search results.
curl -XGET "http://localhost:9200/page_index/_search?pretty=true" -d '{"query": {"queryString": {"default_operator":"AND","query":"test"}}, "filter" : {"term" : {number": 2 }}}'
4) A similar search query for the word "test" but applying a filter on a string field returns no results.
curl -XGET "http://localhost:9200/page_index/_search?pretty=true" -d '{"query": {"queryString": {"default_operator":"AND","query":"test"}}, "filter" : {"term" : {"name": "blah" }}}'
5) If the Analyzer type is changed from "snowball" to standard, both the above search queries return the expected results. Any ideas?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment