Created
April 11, 2012 10:11
-
-
Save imotov/2358376 to your computer and use it in GitHub Desktop.
Specific analyzer per document repro
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
echo "Deleting the test index" | |
curl -XDELETE localhost:9200/test-idx | |
echo | |
echo "Creating the test index" | |
curl -XPUT localhost:9200/test-idx -d '{ | |
"settings": { | |
"index" : { | |
"number_of_shards" : 1, | |
"number_of_replicas" : 0 | |
} | |
} | |
}' | |
echo | |
echo "Setting mapping" | |
curl -XPUT localhost:9200/test-idx/content/_mapping -d '{"content": { | |
"_source" : {"enabled" : true}, | |
"_uid" : {"index" : "no", "store" : "no"}, | |
"_id" : {"index" : "no", "store" : "yes"}, | |
"_analyzer" : {"path" : "my_anal", "index" : "no"}, | |
"_index" : {"enabled" : true, "index" : "no", "store" : "yes"}, | |
"properties" : { | |
"body" : {"type" : "string", | |
"store" : "yes", | |
"index" : "analyzed", | |
"boost" : 1.0, | |
"term_vector" : "with_positions_offsets" | |
}} | |
}}' | |
echo | |
echo "----------------------------------------------------------------------" | |
echo "Indexing a record with the standard analyzer" | |
curl -XPUT localhost:9200/test-idx/content/1 -d '{"body" : "this is testing", "my_anal" : "standard"}' | |
echo | |
curl -XPOST localhost:9200/test-idx/_refresh | |
echo | |
echo "Should get back one token 'testing'" | |
curl -XGET localhost:9200/test-idx/_search\?pretty=true -d '{ | |
"query": { | |
"query_string": { | |
"query": "_id:1" | |
} | |
}, | |
"facets": { | |
"terms1": { | |
"terms": { | |
"field": "body" | |
} | |
} | |
} | |
}' | |
echo | |
echo "----------------------------------------------------------------------" | |
echo "Indexing a record with the keyword analyzer" | |
curl -XPUT localhost:9200/test-idx/content/2 -d '{"body" : "this is testing", "my_anal" : "keyword"}' | |
echo | |
curl -XPOST localhost:9200/test-idx/_refresh | |
echo | |
echo "Should get back one token 'this is testing'" | |
curl -XGET localhost:9200/test-idx/_search\?pretty=true -d '{ | |
"query": { | |
"query_string": { | |
"query": "_id:2" | |
} | |
}, | |
"facets": { | |
"terms1": { | |
"terms": { | |
"field": "body" | |
} | |
} | |
} | |
}' | |
echo | |
echo "----------------------------------------------------------------------" | |
echo "Indexing a record with the snowball analyzer" | |
curl -XPUT localhost:9200/test-idx/content/3 -d '{"body" : "this is testing", "my_anal" : "snowball"}' | |
echo | |
curl -XPOST localhost:9200/test-idx/_refresh | |
echo | |
echo "Should get back one token 'test'" | |
curl -XGET localhost:9200/test-idx/_search\?pretty=true -d '{ | |
"query": { | |
"query_string": { | |
"query": "_id:3" | |
} | |
}, | |
"facets": { | |
"terms1": { | |
"terms": { | |
"field": "body" | |
} | |
} | |
} | |
}' | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment