Created
April 10, 2012 23:03
-
-
Save sheroy/2355404 to your computer and use it in GitHub Desktop.
Elastic Search filtering with the snowball Analyzer
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
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