Last active
December 21, 2015 18:29
-
-
Save plusjade/6348036 to your computer and use it in GitHub Desktop.
Elasticsearch-ing How I make sense of what the hell is going on in ES. Essentially a "control test" environment. Validate the minimum possible use-case, then iterate by one factor. Note I don't have any comments in there because you can copy and paste the entire top half into console and it will run in sequence.
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/p' | |
| curl -XPOST 'http://localhost:9200/p' -d ' | |
| { | |
| "index" : { | |
| "analysis" : { | |
| "analyzer" : { | |
| "default_index" : { | |
| "tokenizer" : "standard", | |
| "filter" : ["lowercase", "asciifolding", "mynGram"], | |
| "type" : "custom" | |
| }, | |
| "default_search" : { | |
| "tokenizer" : "standard", | |
| "filter" : ["lowercase", "asciifolding"], | |
| "type" : "custom" | |
| }, | |
| "pronoun_stream_analyzer": { | |
| "type" : "custom", | |
| "filter" : ["lowercase", "asciifolding"], | |
| "tokenizer" : "keyword" | |
| } | |
| } | |
| , | |
| "filter" : { | |
| "mynGram" : { | |
| "type" : "edgeNGram", | |
| "min_gram" : 1, | |
| "max_gram" : 50 | |
| }, | |
| "searchkick_search_shingle": { | |
| "type": "shingle", | |
| "max_shingle_sizes" : 3 | |
| } | |
| } | |
| } | |
| } | |
| } | |
| ' | |
| curl -XPOST 'localhost:9200/p/profile/_mapping' -d ' | |
| { | |
| "profile": { | |
| "properties": { | |
| "name": {"type" : "string", "analyzer" : "default_index","store": true } | |
| } | |
| } | |
| } | |
| }' | |
| curl -XPOST localhost:9200/p/profile -d '{ "name" : "Lucapette" }' | |
| curl -XPOST localhost:9200/p/profile -d '{ "name" : "Lucas" }' | |
| curl -XPOST localhost:9200/p/profile -d '{ "name" : "Luca" }' | |
| curl -XPOST localhost:9200/p/profile -d '{ "name" : "Jade Dominguez" }' | |
| curl -XPOST localhost:9200/p/profile -d '{ "name" : "Jade Dominguez Jr." }' | |
| curl -XPOST localhost:9200/p/profile -d '{ "name" : "Dr. Jade Dominguez" }' | |
| curl -XPOST localhost:9200/p/profile -d '{ "name" : "Dr Jade Dominguez" }' | |
| curl -XPOST localhost:9200/p/profile -d '{ "name" : "Jade" }' | |
| curl -XPOST localhost:9200/p/profile -d '{ "name" : "Robert Jade" }' | |
| curl -XPOST localhost:9200/p/profile -d '{ "name" : "Samjade HO" }' | |
| curl -XPOST localhost:9200/p/profile -d '{ "name" : "Jade F" }' | |
| curl -XPOST "http://localhost:9200/p/_refresh" | |
| curl -XGET 'localhost:9200/p/_search?&search_type=dfs_query_then_fetch&pretty=true' -d '{ | |
| "query": { | |
| "query_string": { | |
| "query": "name:Jad", | |
| "default_operator" : "AND" | |
| } | |
| }, | |
| "explain": false | |
| }' | |
| curl -XGET 'localhost:9200/p/_search?&search_type=dfs_query_then_fetch&pretty=true' -d '{ | |
| "query": { | |
| "match": { | |
| "name" : { | |
| "query": "luca", | |
| "operator": "AND", | |
| "type" : "phrase_prefix", | |
| "max_expansions": 10, | |
| "phrase_slop": 3, | |
| "boost" : 10 | |
| } | |
| } | |
| }, | |
| "explain": true | |
| }' | |
| curl -XGET 'localhost:9200/p/_search?&search_type=dfs_query_then_fetch&pretty=true' -d '{ | |
| "query": { | |
| "dis_max": { | |
| "queries": [ | |
| { | |
| "match": { | |
| "name" : { | |
| "query": "lucap", | |
| "operator": "AND", | |
| "boost" : 10 | |
| } | |
| } | |
| } | |
| , | |
| { | |
| "match": { | |
| "name" : { | |
| "query": "lucap", | |
| "operator": "AND", | |
| "type" : "phrase_prefix", | |
| "max_expansions": 10, | |
| "phrase_slop": 3 | |
| } | |
| } | |
| } | |
| ] | |
| } | |
| }, | |
| "explain": false | |
| }' | |
| curl -XGET "http://localhost:9200/p/_status" | |
| curl -XGET 'localhost:9200/p/_search?&search_type=dfs_query_then_fetch&pretty=true' -d '{ | |
| "query": { | |
| "filtered": { | |
| "query": { | |
| "bool": { | |
| "must": [ | |
| { | |
| "query_string": { | |
| "query": "Ozgür~", | |
| "default_operator": "AND", | |
| "fields": [ | |
| "name" | |
| ] | |
| } | |
| } | |
| ] | |
| } | |
| } | |
| } | |
| }, | |
| "size": 20, | |
| "from": 0 | |
| }' | |
| curl -XGET 'localhost:9200/p/_search?&search_type=dfs_query_then_fetch&pretty=true' -d '{ | |
| "query": { | |
| "filtered": { | |
| "query": { | |
| "bool": { | |
| "must": [ | |
| { | |
| "multi_match": { | |
| "query": "Ozgüra", | |
| "operator": "AND", | |
| "fuzziness" : "0.9", | |
| "fields": [ | |
| "name" | |
| ] | |
| } | |
| } | |
| ] | |
| } | |
| } | |
| } | |
| }, | |
| "size": 20, | |
| "from": 0 | |
| }' | |
| curl -XGET 'localhost:9200/p/_search?&search_type=dfs_query_then_fetch&pretty=true' -d '{ | |
| "query": { | |
| "bool": { | |
| "must": [ | |
| { | |
| "match" : { | |
| "name" : { | |
| "query" : "meep test", | |
| "operator" : "and", | |
| "fuzziness": "0.9" | |
| } | |
| } | |
| } | |
| ] | |
| } | |
| }, | |
| "size": 20, | |
| "from": 0 | |
| }' | |
| curl -XGET 'localhost:9200/p/_search?&search_type=dfs_query_then_fetch&pretty=true' -d '{ | |
| "query": { | |
| "bool": { | |
| "must": [ | |
| { | |
| "fuzzy": { | |
| "name" : { | |
| "value" : "Jade", | |
| "min_similarity" : 0.5 | |
| } | |
| } | |
| } | |
| ] | |
| } | |
| }, | |
| "size": 20, | |
| "from": 0 | |
| }' | |
| curl -XGET 'localhost:9200/p/_search?&search_type=dfs_query_then_fetch&pretty=true' -d '{ | |
| "query": { | |
| "filtered": { | |
| "query": { | |
| "dis_max": { | |
| "queries": [ | |
| { | |
| "match": { | |
| "name" : { | |
| "query": "__sam", | |
| "operator": "AND", | |
| "type" : "phrase_prefix", | |
| "max_expansions": 10, | |
| "phrase_slop": 3, | |
| "boost" : 10 | |
| } | |
| } | |
| } | |
| , | |
| { | |
| "match": { | |
| "name" : { | |
| "query": "__sam", | |
| "operator": "AND", | |
| "max_expansions": 10, | |
| "fuzziness": 0.3 | |
| } | |
| } | |
| } | |
| , | |
| { | |
| "fuzzy": { | |
| "name" : { | |
| "value" : "samm", | |
| "min_similarity" : 0.2 | |
| } | |
| } | |
| } | |
| ] | |
| } | |
| }}}, | |
| "size": 20, | |
| "from": 0 | |
| }' | |
| curl -XGET 'localhost:9200/p/_analyze?&pretty=true' -d 'Luca blah' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment