Created
July 27, 2011 10:50
-
-
Save vshkurin/1109136 to your computer and use it in GitHub Desktop.
ElasticSearch Test Queries
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
| # Index | |
| --------------------------------------------------------------------- | |
| curl -XPUT http://localhost:9200/pictures/ -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 | |
| } | |
| } | |
| } | |
| } | |
| }' | |
| _____________________________________________________________________ | |
| # Mapping | |
| --------------------------------------------------------------------- | |
| curl -XPUT 'http://localhost:9200/pictures/picture/_mapping' -d ' | |
| { | |
| "picture": { | |
| "_all" : {"enabled" : true, "index_analyzer": "index_analyzer", "search_analyzer": "search_analyzer"}, | |
| "properties": { | |
| "id": { | |
| "type": "string", | |
| "index": "not_analyzed" | |
| }, | |
| "title": { | |
| "type": "string", | |
| "boost": 7.0, | |
| "index": "analyzed", | |
| "index_analyzer": "index_analyzer", | |
| "search_analyzer": "search_analyzer", | |
| "store": "yes" | |
| }, | |
| "description": { | |
| "type": "string", | |
| "boost": 1.0, | |
| "index": "analyzed", | |
| "index_analyzer": "index_analyzer", | |
| "search_analyzer": "search_analyzer" | |
| }, | |
| "featured": { | |
| "type": "boolean", | |
| "boost": 10.0, | |
| "index": "not_analyzed" | |
| }, | |
| "categories": { | |
| "type": "string", | |
| "boost": 2.0, | |
| "index_name": "category", | |
| "index": "analyzed", | |
| "index_analyzer": "index_analyzer", | |
| "search_analyzer": "search_analyzer", | |
| "store": "yes" | |
| }, | |
| "tags": { | |
| "type": "string", | |
| "boost": 4.0, | |
| "index_name": "tag", | |
| "index": "analyzed", | |
| "index_analyzer": "index_analyzer", | |
| "search_analyzer": "search_analyzer", | |
| "store": "yes" | |
| }, | |
| "created_at": { | |
| "type": "double", | |
| "index": "not_analyzed" | |
| } | |
| } | |
| } | |
| }' | |
| _____________________________________________________________________ | |
| # Some data | |
| --------------------------------------------------------------------- | |
| { | |
| "picture" { | |
| "id" : "4df1ad2df10a854a9d000026" | |
| "title" : "Birds on the beach", | |
| "description" : "", | |
| "featured" : false, | |
| "categories" : ["Landscapes","Nature"], | |
| "tags" : ["beach","landscape","ocean","sand","sky","birds"], | |
| "created_at" : 1307684141.682636 | |
| } | |
| } | |
| { | |
| "picture" { | |
| "id" : "4defd951f10a8524b8000005" | |
| "title" : "Rock on the beach", | |
| "description" : "", | |
| "featured" : false, | |
| "categories" : ["Landscapes","Nature"], | |
| "tags" : ["beach","landscape","ocean","rock","sand","seaside","sky"], | |
| "created_at" : 11307564214.04741 | |
| } | |
| } | |
| { | |
| "picture" { | |
| "id" : "4deff7fcf10a8527e4000012" | |
| "title" : "Rock in the ocean", | |
| "description" : "", | |
| "featured" : false, | |
| "categories" : ["Landscapes","Nature"], | |
| "tags" : ["beach","landscape","ocean","rock","sand","seaside","sky"], | |
| "created_at" : 1307572220.6159518 | |
| } | |
| } | |
| { | |
| "picture" { | |
| "id" : "4defe065f10a8524b8000040" | |
| "title" : "Beautiful sunset over the ocean", | |
| "description" : "", | |
| "featured" : false, | |
| "categories" : ["Landscapes","Nature"], | |
| "tags" : ["landscape","ocean","sky","sunset"], | |
| "created_at" : 1307564214.04741 | |
| } | |
| } | |
| { | |
| "picture" { | |
| "id" : "4df1acaef10a854a9d000020" | |
| "title" : "Purple sunset", | |
| "description" : "", | |
| "featured" : false, | |
| "categories" : ["Landscapes","Nature"], | |
| "tags" : ["landscape","ocean","sunset"], | |
| "created_at" : 1307684014.390545 | |
| } | |
| } | |
| { | |
| "picture" { | |
| "id" : "4df1b7fcf10a854a9d000077" | |
| "title" : "", | |
| "description" : "", | |
| "featured" : false, | |
| "categories" : ["Landscapes","Nature"], | |
| "tags": ["ocean"], | |
| "created_at" : 1307686908.699473 | |
| } | |
| } | |
| { | |
| "picture" { | |
| "id" : "4defe0ecf10a8524b8000047" | |
| "title" : "Victoria's Secret photoshoot", | |
| "description" : "", | |
| "featured" : false, | |
| "categories" : ["Fashion", "Girls"], | |
| "tags": ["girl", "photoshoot", "supermodel", "Victoria's Secret"], | |
| "created_at" : 1307564214.04741 | |
| } | |
| } | |
| _____________________________________________________________________ | |
| # Queries for word delemiter | |
| --------------------------------------------------------------------- | |
| 1. OK | |
| http://localhost:9200/pictures/_search?q=victoria's | |
| { "hits" : {"total":1 ... "_id":"4defe0ecf10a8524b8000047" ... } } | |
| 2. OK | |
| http://localhost:9200/pictures/_search?q=tags:victorias | |
| { "hits" : {"total":1 ... "_id":"4defe0ecf10a8524b8000047" ... } } | |
| 3. OK | |
| http://localhost:9200/pictures/_search?q=victorias | |
| { "hits" : {"total":1 ... "_id":"4defe0ecf10a8524b8000047" ... } } | |
| 4. OK | |
| http://localhost:9200/pictures/_search?q=victoria | |
| { "hits" : {"total":1 ... "_id":"4defe0ecf10a8524b8000047" ... } } | |
| _____________________________________________________________________ | |
| # Queries for stemming | |
| --------------------------------------------------------------------- | |
| 1. OK | |
| http://localhost:9200/pictures/_search?q=birds | |
| { "hits" : {"total":1 ... "_id":"4df1ad2df10a854a9d000026" ... } } | |
| 2. OK | |
| http://localhost:9200/pictures/_search?q=tags:bird | |
| { "hits" : {"total":1 ... "_id":"4df1ad2df10a854a9d000026" ... } } | |
| 3. OK | |
| http://localhost:9200/pictures/_search?q=bird | |
| { "hits" : {"total":1 ... "_id":"4df1ad2df10a854a9d000026" ... } } | |
| _____________________________________________________________________ | |
| # Queries for "More Like This" | |
| --------------------------------------------------------------------- | |
| 1. OK | |
| http://localhost:9200/pictures/picture/4defe065f10a8524b8000040/_mlt?min_term_freq=1&min_doc_freq=1 | |
| { "hits" : {"total":5 ...}} | |
| 2. OK | |
| http://localhost:9200/pictures/picture/4df1b7fcf10a854a9d000077/_mlt?min_term_freq=1&min_doc_freq=1 | |
| { "hits" : {"total":5 ...}} | |
| ... | |
| 5. OK | |
| http://localhost:9200/pictures/picture/4deff7fcf10a8527e4000012/_mlt?mlt_fields=categories&min_term_freq=1&min_doc_freq=1 | |
| { "hits" : {"total":5 ...}} | |
| _____________________________________________________________________ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thankyou very very much!!! This aproach works!!!
Own you a beer!