Created
October 1, 2010 14:55
-
-
Save angelf/606312 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| ----- | |
| delete the index if it exists | |
| {"ok":true,"acknowledged":true} | |
| ----- | |
| create it with 'folded_analyzer' that includes the 'asciifolding' | |
| {"ok":true,"acknowledged":true} | |
| ----- | |
| create a mapping for 'title' using the folded_analyzer | |
| {"ok":true,"acknowledged":true} | |
| ----- | |
| check that the mapping has been correctly stored | |
| { | |
| "test" : { | |
| "document" : { | |
| "_boost" : { | |
| "name" : "_boost" | |
| }, | |
| "dynamic" : true, | |
| "_type" : { | |
| "store" : "no" | |
| }, | |
| "enabled" : true, | |
| "date_formats" : [ "dateOptionalTime", "yyyy/MM/dd HH:mm:ss||yyyy/MM/dd" ], | |
| "_source" : { | |
| "enabled" : true, | |
| "name" : "_source" | |
| }, | |
| "_id" : { | |
| "store" : "no" | |
| }, | |
| "_index" : { | |
| "enabled" : false, | |
| "store" : "no" | |
| }, | |
| "path" : "full", | |
| "properties" : { | |
| "title" : { | |
| "omit_term_freq_and_positions" : false, | |
| "index_name" : "title", | |
| "index" : "analyzed", | |
| "index_analyzer" : "folded_analyzer", | |
| "omit_norms" : false, | |
| "store" : "yes", | |
| "search_analyzer" : "folded_analyzer", | |
| "boost" : 1.0, | |
| "term_vector" : "no", | |
| "type" : "string" | |
| } | |
| }, | |
| "_all" : { | |
| "enabled" : true, | |
| "store" : "no", | |
| "term_vector" : "no" | |
| }, | |
| "type" : "object" | |
| } | |
| } | |
| } | |
| ----- | |
| index 3 documents | |
| {"ok":true,"_index":"test","_type":"document","_id":"1"}{"ok":true,"_index":"test","_type":"document","_id":"2"}{"ok":true,"_index":"test","_type":"document","_id":"3"} | |
| ----- | |
| search using _all | |
| { | |
| "_shards" : { | |
| "total" : 5, | |
| "successful" : 5, | |
| "failed" : 0 | |
| }, | |
| "hits" : { | |
| "total" : 1, | |
| "max_score" : 0.13561106, | |
| "hits" : [ { | |
| "_index" : "test", | |
| "_type" : "document", | |
| "_id" : "1", | |
| "_score" : 0.13561106, "_source" : {"title" : "cafe solo"} | |
| } ] | |
| } | |
| } | |
| ----- | |
| search using the field | |
| { | |
| "_shards" : { | |
| "total" : 5, | |
| "successful" : 5, | |
| "failed" : 0 | |
| }, | |
| "hits" : { | |
| "total" : 1, | |
| "max_score" : 0.19178301, | |
| "hits" : [ { | |
| "_index" : "test", | |
| "_type" : "document", | |
| "_id" : "1", | |
| "_score" : 0.19178301, "_source" : {"title" : "cafe solo"} | |
| } ] | |
| } | |
| } |
This file contains hidden or 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
| echo | |
| echo "-----" | |
| echo "delete the index if it exists" | |
| curl -XDELETE 'http://esearch:9200/test/' | |
| echo | |
| echo "-----" | |
| echo "create it with 'folded_analyzer' that includes the 'asciifolding' " | |
| curl -XPUT 'http://esearch:9200/test/' -d ' | |
| index: | |
| number_of_shards : 5 | |
| number_of_replicas : 3 | |
| analysis: | |
| analyzer: | |
| folded_analyzer: | |
| type : standard | |
| filter: ["standard", "lowercase", "stop", "asciifolding"] | |
| '; | |
| echo | |
| echo "-----" | |
| echo "create a mapping for 'title' using the folded_analyzer" | |
| curl -XPUT 'http://esearch:9200/test/document/_mapping' -d ' | |
| { | |
| "document" : { | |
| "properties" : { | |
| "title" : {"type" : "string", "store" : "yes", "analyzer" : "folded_analyzer"} | |
| } | |
| } | |
| } | |
| '; | |
| echo | |
| echo "-----" | |
| echo "check that the mapping has been correctly stored" | |
| curl 'http://esearch:9200/test/document/_mapping?pretty=1' | |
| echo | |
| echo "-----" | |
| echo "index 3 documents" | |
| curl -XPUT 'http://esearch:9200/test/document/1' -d '{"title" : "cafe solo"}' | |
| curl -XPUT 'http://esearch:9200/test/document/2' -d '{"title" : "café cortado"}' | |
| curl -XPUT 'http://esearch:9200/test/document/3' -d '{"title" : "café con leche"}' | |
| echo | |
| echo "-----" | |
| echo "search using _all" | |
| curl 'http://esearch:9200/test/_search?q=cafe&pretty=1' | |
| echo | |
| echo "-----" | |
| echo "search using the field" | |
| curl 'http://esearch:9200/test/_search?q=title:cafe&pretty=1' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment