Created
February 7, 2013 14:10
-
-
Save lukas-vlcek/4731127 to your computer and use it in GitHub Desktop.
Elasticsearch: Define custom analysers and common field mappings in index template
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
#!/bin/sh | |
curl -XPUT localhost:9200/index_1 -d' | |
{ | |
settings: { | |
number_of_shards: 1, | |
number_of_replicas: 0 | |
}, | |
mappings: { | |
_default_ : { | |
properties: { | |
dcp_type : {type : "string", index : "not_analyzed", include_in_all : false} | |
} | |
}, | |
other_type : { | |
properties : { | |
dcp_type : {type : "string", index : "not_analyzed", include_in_all : false} | |
} | |
} | |
} | |
}' | |
# note we are indexing into 'mytype' thus 'other_type' mapping does not apply, only '_default_' mapping does | |
curl -X POST 'http://localhost:9200/index_1/mytype/' -d '{ | |
dcp_type : "trying out Elastic Search" | |
}' | |
curl -X GET 'http://localhost:9200/_search' -d ' | |
{ | |
query : { | |
query_string : { | |
default_field : "dcp_type", | |
query : "\"trying out Elastic Search\"" | |
} | |
} | |
}' | |
curl -X GET 'http://localhost:9200/_search' -d ' | |
{ | |
query : { | |
query_string : { | |
query : "dcp_type:\"trying out Elastic Search\"" | |
} | |
} | |
}' | |
curl -X GET 'http://localhost:9200/_search' -d ' | |
{ | |
query : { | |
term : { | |
dcp_type : "trying out Elastic Search" | |
} | |
} | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment