Created
April 7, 2012 12:58
-
-
Save jprante/2328676 to your computer and use it in GitHub Desktop.
for chepa
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
curl -XDELETE http://localhost:9200/myapp | |
curl -XPUT http://localhost:9200/myapp/ -d ' | |
{ | |
"settings": { | |
"analysis": { | |
"analyzer": { | |
"index_analyzer": { | |
"tokenizer": "standard", | |
"filter": ["standard", "my_delimiter", "lowercase", "stop", "asciifolding", "porter_stem"] | |
}, | |
"search_analyzer": { | |
"tokenizer": "standard", | |
"filter": ["standard", "lowercase", "stop", "asciifolding", "porter_stem"] | |
} | |
}, | |
"filter": { | |
"my_delimiter": { | |
"type": "word_delimiter", | |
"generate_word_parts": true, | |
"catenate_words": true, | |
"catenate_numbers": true, | |
"catenate_all": true, | |
"split_on_case_change": true, | |
"preserve_original": true, | |
"split_on_numerics": true, | |
"stem_english_possessive": true | |
} | |
} | |
} | |
} | |
}' | |
curl -XPUT http://localhost:9200/myapp/product/_mapping/ -d ' | |
{ | |
"product" : { | |
"properties": { | |
"name": { | |
"index": "analyzed", | |
"type": "string", | |
"index_analyzer": "index_analyzer", | |
"search_analyzer": "search_analyzer", | |
"store": "yes" | |
}, | |
"category_id": { | |
"index": "analyzed", | |
"type": "integer", | |
"index_analyzer": "index_analyzer", | |
"search_analyzer": "search_analyzer", | |
"store": "yes" | |
}, | |
"price": { | |
"index": "analyzed", | |
"type": "double", | |
"index_analyzer": "index_analyzer", | |
"search_analyzer": "search_analyzer", | |
"store": "yes" | |
}, | |
"price_high": { | |
"index": "analyzed", | |
"index_analyzer": "index_analyzer", | |
"search_analyzer": "search_analyzer", | |
"type": "double" | |
}, | |
"price_low": { | |
"index": "analyzed", | |
"index_analyzer": "index_analyzer", | |
"search_analyzer": "search_analyzer", | |
"type": "double" | |
} | |
} | |
} | |
}' | |
curl -XPUT http://localhost:9200/myapp/product/1 -d '{ | |
"name" : "Shampoo Biolift with Joy and Ashes", | |
"category_id" : 5, | |
"price" : 6.3931, | |
"price_high" : 12.731, | |
"price_low" : 4.91 | |
}' | |
curl -XPUT http://localhost:9200/myapp/product/2 -d '{ | |
"name" : "Notebook ASUS 16GB 1TB 17in", | |
"category_id" : 2, | |
"price" : 1945.3931, | |
"price_high" : 2500.61, | |
"price_low" : 1800.15 | |
}' | |
curl -XPUT http://localhost:9200/myapp/product/3 -d '{ | |
"name" : "Notebook VAIO 8GB 1TB 14in", | |
"category_id" : 2, | |
"price" : 1045.3931, | |
"price_high" : 1765.21, | |
"price_low" : 780.66 | |
}' | |
curl -XPUT http://localhost:9200/myapp/product/4 -d '{ | |
"name" : "Notebook HP 2GB 500GB 14in", | |
"category_id" : 2, | |
"price" : 945.3931, | |
"price_high" : 1000.6731, | |
"price_low" : 645.91 | |
}' | |
curl -XGET http://localhost:9200/myapp/product/_search -d '{ | |
"query" : { | |
"bool" : { | |
"must" : { | |
"text" : { "name" : "asus" } | |
}, | |
"must" : { | |
"range" : { | |
"price_low" : { | |
"gte" : 1800.15 | |
} | |
} | |
}, | |
"must" : { | |
"range" : { | |
"price_high" : { | |
"lte" : 2500.61 | |
} | |
} | |
} | |
} | |
} | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment