Created
October 18, 2016 17:16
-
-
Save dakrone/022cf20c8e390c4063aa263cd9370e5a to your computer and use it in GitHub Desktop.
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
PUT /test | |
{ | |
"settings": { | |
"index": { | |
"number_of_shards": 1, | |
"number_of_replicas": 0, | |
"analysis": { | |
"analyzer": { | |
"my_ngrams": { | |
"type": "custom", | |
"tokenizer": "standard", | |
"filter": ["my_ngrams"] | |
} | |
}, | |
"filter": { | |
"my_ngrams": { | |
"type": "ngram", | |
"min_gram": 2, | |
"max_gram": 2 | |
} | |
} | |
} | |
} | |
}, | |
"mappings": { | |
"doc": { | |
"properties": { | |
"f1": {"type": "text"}, | |
"f2": {"type": "keyword"}, | |
"f3": {"type": "text", "analyzer": "my_ngrams"}, | |
"f_multi": { | |
"type": "text", | |
"fields": { | |
"raw": {"type": "keyword"}, | |
"f_token_count": {"type": "token_count", "analyzer": "standard"} | |
} | |
}, | |
"f_object": { | |
"type": "object", | |
"properties": { | |
"sub1": {"type": "text"}, | |
"sub2": {"type": "keyword"}, | |
"sub3": {"type": "integer"} | |
} | |
}, | |
"f_nested": { | |
"type": "nested", | |
"properties": { | |
"nest1": {"type": "text"}, | |
"nest2": {"type": "keyword"}, | |
"nest3": {"type": "integer"} | |
} | |
}, | |
"f_date": { | |
"type": "date", | |
"format": "yyyy/MM/dd||epoch_millis" | |
}, | |
"f_bool": {"type": "boolean"}, | |
"f_byte": {"type": "byte"}, | |
"f_short": {"type": "short"}, | |
"f_int": {"type": "integer"}, | |
"f_long": {"type": "long"}, | |
"f_float": {"type": "float"}, | |
"f_hfloat": {"type": "half_float"}, | |
"f_sfloat": {"type": "scaled_float", "scaling_factor": 100}, | |
"f_ip": {"type": "ip"}, | |
"f_binary": {"type": "binary"}, | |
"f_suggest": {"type": "completion"}, | |
"f_geop": {"type": "geo_point"}, | |
"f_geos": {"type": "geo_shape"} | |
} | |
} | |
} | |
} | |
PUT /test/doc/1 | |
{ | |
"f1": "foo", | |
"f2": "Bar", | |
"f3": "foo bar baz", | |
"f_multi": "Foo Bar Baz", | |
"f_object": { | |
"sub1": "sfoo", | |
"sub2":"sbar", | |
"sub3":19 | |
}, | |
"f_nested": { | |
"nest1": "nfoo", | |
"nest2":"nbar", | |
"nest3":21 | |
}, | |
"f_date": "1476383971", | |
"f_bool": "true", | |
"f_byte": "7", | |
"f_short": "23", | |
"f_int": "1293", | |
"f_long": "42", | |
"f_float": "1.7", | |
"f_hfloat": "1.5", | |
"f_sfloat": "12.23", | |
"f_ip": "127.0.0.1", | |
"f_binary": "VGhpcyBpcyBzb21lIGJpbmFyeSBkYXRhCg==", | |
"f_suggest": { | |
"input": ["Nevermind", "Nirvana"], | |
"weight": 34 | |
}, | |
"f_geop": "41.12,-71.34", | |
"f_geos": { | |
"type": "point", | |
"coordinates": [-77.03653, 38.897676] | |
} | |
} | |
PUT /test/doc/2 | |
{ | |
"f1": "foo", | |
"f_int": "11111111" | |
} | |
POST /test/_search?pretty | |
{ | |
"query": { | |
"query_string": { | |
"query": "foo AND 11111111", | |
"fields": ["f*"], | |
"lenient": true | |
} | |
} | |
// ,"explain": true | |
} | |
// Results in: | |
{ | |
"took" : 6, | |
"timed_out" : false, | |
"_shards" : { | |
"total" : 1, | |
"successful" : 1, | |
"failed" : 0 | |
}, | |
"hits" : { | |
"total" : 2, | |
"max_score" : 1.1823215, | |
"hits" : [ | |
{ | |
"_index" : "test", | |
"_type" : "doc", | |
"_id" : "2", | |
"_score" : 1.1823215, | |
"_source" : { | |
"f1" : "foo", | |
"f_int" : "11111111" | |
} | |
}, | |
{ | |
"_index" : "test", | |
"_type" : "doc", | |
"_id" : "1", | |
"_score" : 0.7241652, | |
"_source" : { | |
"f1" : "foo", | |
"f2" : "Bar", | |
"f3" : "foo bar baz", | |
"f_multi" : "Foo Bar Baz", | |
"f_object" : { | |
"sub1" : "sfoo", | |
"sub2" : "sbar", | |
"sub3" : 19 | |
}, | |
"f_nested" : { | |
"nest1" : "nfoo", | |
"nest2" : "nbar", | |
"nest3" : 21 | |
}, | |
"f_date" : "1476383971", | |
"f_bool" : "true", | |
"f_byte" : "7", | |
"f_short" : "23", | |
"f_int" : "1293", | |
"f_long" : "42", | |
"f_float" : "1.7", | |
"f_hfloat" : "1.5", | |
"f_sfloat" : "12.23", | |
"f_ip" : "127.0.0.1", | |
"f_binary" : "VGhpcyBpcyBzb21lIGJpbmFyeSBkYXRhCg==", | |
"f_suggest" : { | |
"input" : [ | |
"Nevermind", | |
"Nirvana" | |
], | |
"weight" : 34 | |
}, | |
"f_geop" : "41.12,-71.34", | |
"f_geos" : { | |
"type" : "point", | |
"coordinates" : [ | |
-77.03653, | |
38.897676 | |
] | |
} | |
} | |
} | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment