Skip to content

Instantly share code, notes, and snippets.

@imotov
Created November 15, 2012 19:14
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 imotov/9be449c5072fb643fc82 to your computer and use it in GitHub Desktop.
Save imotov/9be449c5072fb643fc82 to your computer and use it in GitHub Desktop.
curl -XDELETE localhost:9200/high-test
curl -XPUT localhost:9200/high-test -d '{
"settings": {
"index.number_of_shards": 1,
"index.number_of_replicas": 1
},
"mappings": {
"doc": {
"properties": {
"body": {"type": "string", "store": "no", "term_vector": "no"}
}
}
}
}'
echo
curl -XPUT localhost:9200/high-test/doc/1 -d '{
"id": 9052631,
"title": "",
"body": "Carlees iPod>>My IPod.",
"date_published": "2012-11-14T01:51:24.000Z",
"language": "en"
}
'
echo
curl -XPUT localhost:9200/high-test/doc/2 -d '{
"id": 7211941,
"title": "",
"body": "@oneofwimper iPod直視出来ない←",
"date_published": "2012-11-14T13:51:50.000Z",
"language": "en"
}
'
curl -XPOST http://localhost:9200/high-test/_refresh
echo
curl -XPOST "http://localhost:9200/high-test/doc/_search?size=2&from=0&pretty=1" -d '{
"query": {
"filtered": {
"filter": {
"and": {
"filters": [
{"range": {"date_published": {"gte": "2012-11-14T00:00:00"}}},
{"term": {"language": "en"}}
]}},
"query": {
"query_string": {"fields": ["body", "title"], "default_operator": "and", "query": "ipod"}
}}},
"highlight": {
"number_of_fragments": 10, "fragment_size": 10, "pre_tags": [""], "post_tags": [""],
"fields": {
"title": {"number_of_fragments": 0},
"body": {"number_of_fragments": 1}
}
}
}'
echo
curl -XPOST "http://localhost:9200/high-test/doc/_search?size=2&from=0&pretty=1" -d '{
"query": {
"filtered": {
"filter": {
"and": {
"filters": [
{"range": {"date_published": {"gte": "2012-11-14T00:00:00"}}},
{"term": {"language": "en"}}
]}},
"query": {
"query_string": {"fields": ["body", "title"], "default_operator": "and", "query": "ipod"}
}}},
"highlight": {
"number_of_fragments": 10, "fragment_size": 10, "pre_tags": [""], "post_tags": [""],
"fields": {
"title": {"number_of_fragments": 0},
"body": {"number_of_fragments": 1}
}
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment